[英]IIS Express using an unkown user to perform write
I have an ASP.Net MVC web application in which I am trying to allow the user to upload a PDF file to a folder inside the app.我有一个 ASP.Net MVC web 应用程序,我试图在其中允许用户将 PDF 文件上传到应用程序内的文件夹。
string path = "Case_Log_Docs";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
System.Diagnostics.Debug.WriteLine("Created the folder.");
}
if (PostedFile != null)
{
string fileName = Path.GetFileName(PostedFile.FileName);
System.Diagnostics.Debug.WriteLine(fileName);
PostedFile.CopyTo(new FileStream(path, FileMode.Create));
ViewBag.Message += string.Format("<b>{0}</b> uploaded.<br />", fileName);
}
However I am getting an Unauthorized User: Access denied
error.但是我得到一个
Unauthorized User: Access denied
错误。 I used Process Monitor and monitored this application writing a file and a different (and fully operational) application to do the same thing.我使用 Process Monitor 并监视这个应用程序编写一个文件和一个不同的(并且完全可操作的)应用程序来做同样的事情。 I noticed that in the app that is operational IIS Express used myself as the user when attempting (and succeeding) to write the file to the specified folder.
我注意到在正在运行的应用程序中,IIS Express 在尝试(并成功)将文件写入指定文件夹时使用自己作为用户。 However, the the application in question used this value as the user:
S-1-5-21-1092590740-2774964217-3234137035-256211
.但是,有问题的应用程序将此值用作用户:
S-1-5-21-1092590740-2774964217-3234137035-256211
。
I have tried the answers to this question: how to run iisexpress app pool under a different identity我已经尝试过这个问题的答案: how to run iisexpress app pool under a different identity
But for the first answer, I do not have a.config file so that doesn't work.但是对于第一个答案,我没有 .config 文件,所以这不起作用。 I did complete the second answer that directs you to use the runas command but it did not fix my error.
我确实完成了指导您使用 runas 命令的第二个答案,但它没有解决我的错误。
So my 2 questions are:所以我的两个问题是:
1.) Why is IIS Express using this value instead of the current user (myself)? 1.) 为什么 IIS Express 使用这个值而不是当前用户(我自己)?
2.) How do I instruct IIS Express to use myself as the user? 2.) 如何指示 IIS Express 使用自己作为用户? I was not even aware that IIS Express could use anything other than the current user.
我什至不知道 IIS Express 可以使用当前用户以外的任何东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.