0
私はDelegatingHandlerから継承するクラスを持っています。MVC5クラスのファイルにアクセスできない
string filePath = HttpContext.Current.Server.MapPath("~/test.txt");
if (!string.IsNullOrWhiteSpace(filePath))
{
using (StreamWriter w = File.AppendText(filePath))
{
w.WriteLine(string.Format("{0}|{1})", DateTime.Now, ex.ToString()));
}
}
をしかし、私はHttpContext.Current上のヌルエラーがどのような可能性
string filePath = HttpContext.Current.Server.MapPath("~/test.txt");
nullにすることはできません得続ける:そのクラスのメソッドの一つで、私はそうのようなテキストファイルにアクセスしようとしています問題は?ファイルがサイトルートに存在することを確認しましたか?
アプリケーションの現在のフルパスを返します/ 31419033/httpcontext-current-is-null-inside-identity-frameworks-methods)を参照してください。 –
管理者にコンパイラの権限を与えましたか? – omerv2