[英]asp.net c# working with iis express but not with iis local
I am working with asp.net and c# What I want to do is to change the label 'color' and run notepad on clicking button.我正在使用 asp.net 和 c# 我想做的是更改 label 的“颜色”并在单击按钮时运行记事本。 When I am testing this in visual studio (iis express) everything works perfectly but when I run it in iis local the label goes to red but notepad cannot be run.当我在视觉工作室(iis express)中测试它时,一切正常,但是当我在 iis 本地运行它时,label 变为红色,但记事本无法运行。 what am I doing wrong?我究竟做错了什么?
protected void Button1_Click(object sender, EventArgs e)
{
Label1.BackColor = System.Drawing.Color.Red;
System.Diagnostics.Process.Start("C:/Windows/System32/notepad.exe");
}
That's because when you run application in IIS Express, the whole application run under your current login user .这是因为当您在 IIS Express 中运行应用程序时,整个应用程序在您当前的登录用户下运行。 However, when you migrate the application to IIS, everything executed under application pool identity .但是,当您将应用程序迁移到 IIS 时,所有操作都在应用程序池标识下执行。 By default app pool identity(IIS apppool\appoolname) don't have permission to access C:/Windows/System32/notepad.exe.默认情况下,应用程序池标识(IIS apppool\apppoolname)无权访问 C:/Windows/System32/notepad.exe。 So you can try to set app pool identity to local system .因此,您可以尝试将应用程序池标识设置为本地系统。 If it works, then you can replace the identity with your own user.如果它有效,那么您可以将身份替换为您自己的用户。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.