当我使用Visual Studio在本地调试我的网站时,对web.config的更改进入效果没有任何问题.
但是,当我对我的服务器主机(运行IIS 7.5)上的web.config进行相同的更改时,看起来当我在浏览器中加载它时,该站点仍在运行旧版本的web.config.新的更改未应用.
我尝试使用IIS管理器在服务器上停止并启动我的站点的应用程序池,但仍然没有变化.我也试过停止并启动IIS,这也没有用.
我对web.config所做的更改涉及删除块中的条目以允许和拒绝用户.它目前设置为提示凭据,如果有效,则可以访问该站点.如果不是,则拒绝访问.我尝试进行的更改是允许访问所有用户,而不是提示他们提供凭据.
之前:
<authorization>
<deny users="?" />
<allow roles="admins" />
<deny users="*" />
</authorization>
Run Code Online (Sandbox Code Playgroud)
后:
<authorization>
<allow users="*" />
</authorization>
Run Code Online (Sandbox Code Playgroud)
这是什么原因?
在Visual Studio中,我使用提供的模板创建了一个全新的ASP.NET Web窗体应用程序.
我没有对VS自动生成的代码做任何事情,除了将以下内容添加到Global.asax.cs
string myself = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
string me = User.Identity.Name;
Run Code Online (Sandbox Code Playgroud)
String我自己成功存储了当前的Windows登录ID.但是string me是null,因为当我调试时,User为null.但是,Visual Studio在调试之前未显示任何错误.
如何使用User.Identity.Name获取字符串的正确值?
这是我正在使用的代码:
try
{
mainWorker = new BackgroundWorker();
mainWorker.DoWork += (sender, e) =>
{
try
{
//stuff I want to have happen in the background
...
//I want to step through the lines in this try block
}
catch
{
//exception not being caught
}
};
mainWorker.RunWorkerCompleted += (sender, e) =>
{
//code to let user know that the background work is done
...
};
mainWorker.RunWorkerAsync();
mainWorker.Dispose();
}
catch
{
//exception not being caught
}
Run Code Online (Sandbox Code Playgroud)
我看不到抛出任何异常。我在DoWork的try块中设置了一个断点。有时它会到达断点,但是在经过一定数量的行后,程序将结束。它并不总是以同一行代码结尾。有时它根本没有达到断点。
如果我取消后台工作人员,则代码将正常执行。
我以前没有实施过后台工作人员,并且试图弄清我所缺少的内容,这使我无法逐步执行代码。
编辑:忘了提到,如果我注释掉Dispose(),它仍然不会逐步执行。