C# http错误503服务不可用。应用程序池在访问网站时停止
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19652709/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTTP Error 503. The service is unavailable. App pool stops on accessing website
提问by Sandy
There are number of posts on this and I have tried many a things by now. But to no avail. Myself a Winforms Developer basically, started working on this Web stuff few days back as my company is taking Web initiatives.
有很多关于这个的帖子,我现在已经尝试了很多东西。但无济于事。我自己基本上是一个 Winforms 开发人员,几天前我的公司正在采取 Web 计划时开始研究这个 Web 内容。
I have a ASP.Net project and I want to host it on local IIS. In Project properties -> Web
settings I chose Use Local IIS Server
and gave a url as localhost/MyApp
. I tried accessing it on my firefox browser and received error as HTTP Error 503. The service is unavailable.
我有一个 ASP.Net 项目,我想将它托管在本地 IIS 上。在Project properties -> Web
设置中,我选择Use Local IIS Server
并提供了一个 url 为localhost/MyApp
. 我尝试在我的 Firefox 浏览器上访问它并收到错误消息HTTP Error 503. The service is unavailable.
Previously I got many other errors and I one by one fixed them all. But struck with this one. These are the settings I have in my project
以前我遇到了许多其他错误,我一一修复了它们。但被这个击中了。这些是我在项目中的设置
- Application Pool set to ASP.Net v4.0 Classic
- App Pool
Enable 32 bit Application
property is true - App Pool is started
- Project build property set to
Any CPU
for Target framework
- 应用程序池设置为 ASP.Net v4.0 Classic
- 应用程序池
Enable 32 bit Application
属性为真 - 应用池已启动
- 项目构建属性设置
Any CPU
为 Target 框架
But I would like to mention a weird behavior. Following is something that I am facing
但我想提一个奇怪的行为。以下是我面临的事情
- Application Pool is Started
- I try to access my local website (by giving url as
localhost/MyApp
) - I receive the error as
HTTP Error 503. The service is unavailable
- Application Pool is Stopped
- 应用程序池已启动
- 我尝试访问我的本地网站(通过提供 url as
localhost/MyApp
) - 我收到错误为
HTTP Error 503. The service is unavailable
- 应用程序池已停止
I have seen following linkand I have already tried it. For the above behavior I reached here. According to this link, Computer name should not have .
in it. I don't have any .
in my Computer name but do have -
in it. Also my domain name contains .
in it. Moreover I can't change these settings as its my office laptop and our TFS settings are bound to our Domain and Computer Names.
我已经看到以下链接,我已经尝试过了。对于上述行为,我到达了这里。根据此链接,其中不应包含计算机名称.
。.
我的计算机名称中没有任何内容,但确实有-
。我的域名也包含.
在其中。此外,我无法更改这些设置,因为它是我的办公室笔记本电脑和我们的 TFS 设置绑定到我们的域和计算机名称。
Can anyone help me to understand whats happening? Please guide me. Thanks.
谁能帮助我了解发生了什么?请指导我。谢谢。
Edit
编辑
I have following code in Global.asax
. Application_BeginRequest
method is empty in same file.
我在Global.asax
. Application_BeginRequest
方法在同一文件中为空。
protected override void Application_Start(object sender, EventArgs e)
{
base.Application_Start(sender, e);
String _path = String.Concat(System.AppDomain.CurrentDomain.RelativeSearchPath, ";",
System.Environment.GetEnvironmentVariable("PATH"));
System.Environment.SetEnvironmentVariable("PATH", _path, EnvironmentVariableTarget.Process);
MyAppLog.Initialize();
MyAppLog.WriteMessage("Application Started");
}
Update
更新
As per the suggestions in Comment, I am able to run the website from Cassini.
根据评论中的建议,我可以从 Cassini 运行该网站。
采纳答案by Darin Dimitrov
One possible reason this might happen is that the Application Pool in IIS is configured to run under some custom account and this account either doesn't exist or a wrong password has been provided, or the password has been changed. Look at the advanced properties of the Application Pool in IIS for which account it uses.
发生这种情况的一个可能原因是 IIS 中的应用程序池被配置为在某个自定义帐户下运行,而该帐户不存在或提供了错误的密码,或者密码已更改。查看IIS中应用程序池的高级属性,它使用的是哪个帐户。
Also the Event Log might contain more information as to why the Application Pool is stopping immediately on the first request.
此外,事件日志可能包含有关应用程序池为何在第一次请求时立即停止的更多信息。
回答by Tarun
I was facing the same problem, and debugged it using the event logs. First it said that : "The description for Event ID 5059 from source Microsoft-Windows-WAS cannot be found".
我遇到了同样的问题,并使用事件日志对其进行了调试。首先它说:“无法找到来自 Microsoft-Windows-WAS 源的事件 ID 5059 的描述”。
I then turned on WAS using turn windows features on/off. Then i saw this in eventvwr "Microsoft-Windows-DistributedCOM cannot be found".
然后我使用turn windows features on/off打开 WAS 。然后我在 eventvwr “找不到 Microsoft-Windows-DistributedCOM”中看到了这一点。
Finally I gave up and deleted the App Pool (that used to stop on accessing the website) and created it again, as it is. This resolved the problem.
最后我放弃并删除了应用程序池(用于停止访问网站)并重新创建它,原样。这解决了问题。
回答by Orhan Celik
If you have McAfee HIPS and if you see the following error in event viewer application log:
如果您有 McAfee HIPS 并且在事件查看器应用程序日志中看到以下错误:
The Module DLL C:\Windows\System32\inetsrv\HipIISEngineStub.dll failed to load.
The data is the error.
模块 DLL C:\Windows\System32\inetsrv\HipIISEngineStub.dll 加载失败。
数据是错误的。
Then the following resolved the issue in my case: https://kc.mcafee.com/corporate/index?page=content&id=KB72677&actp=LIST
然后以下解决了我的问题:https: //kc.mcafee.com/corporate/index?page=content&id=KB72677&actp=LIST
Quote from the page:
从页面引用:
- Click Start, Run, type explorer and click OK.
- Navigate to: %windir%\system32\inetsrv\config
- Open the file applicationHost.config as Administrator for editing in Notepad.
Edit the <globalModules> section and remove the following line:
<add name="MfeEngine" image="%windir%\System32\inetsrv\HipIISEngineStub.dll" />Edit the <modules> section and remove the following line:
<add name="MfeEngine" />- After you have finished editing the applicationHost.config file, save the file, then restart the IIS server using iisreset or by restarting the system.
- 单击开始,运行,键入资源管理器,然后单击确定。
- 导航到:%windir%\system32\inetsrv\config
- 以管理员身份打开文件 applicationHost.config 以在记事本中进行编辑。
编辑 <globalModules> 部分并删除以下行:
<add name="MfeEngine" image="%windir%\System32\inetsrv\HipIISEngineStub.dll" />编辑 <modules> 部分并删除以下行:
<add name="MfeEngine" />- 完成对 applicationHost.config 文件的编辑后,保存该文件,然后使用 iisreset 或通过重新启动系统来重新启动 IIS 服务器。
回答by ShaneC
I had a similar issue, all my app pools were stopping whenever a web request was made to them. Although I was getting the following error in the Event Viewer:
我遇到了类似的问题,每当向它们发出 Web 请求时,我的所有应用程序池都会停止。虽然我在事件查看器中收到以下错误:
The worker process for application pool 'appPoolName' encountered an error 'Configuration file is not well-formed XML ' trying to read configuration data from file '\?\C:\inetpub\temp\apppools\appPoolName\appPoolName.config', line number '3'. The data field contains the error code.
应用程序池“appPoolName”的工作进程遇到错误“配置文件格式不正确的 XML”试图从文件“\?\C:\inetpub\temp\apppools\appPoolName\appPoolName.config”中读取配置数据,行数字“3”。数据字段包含错误代码。
Which told me that there were errors in the application.config at:
这告诉我在 application.config 中有错误:
C:\Windows\System32\inetsrv\config\applicationHost.config
C:\Windows\System32\inetsrv\config\applicationHost.config
In my scenario, I edited the web.config on deploy with an element IIS clearly dislikes, the applicationHost.config scraped the web.config and inserted this bad element and wouldn't resolve until I manually removed it
在我的场景中,我在部署时编辑了 web.config,其中包含一个 IIS 明显不喜欢的元素,applicationHost.config 抓取了 web.config 并插入了这个坏元素,并且在我手动删除它之前无法解析
回答by David
For my situation is that my login password changed, while the application pool still uses the old one. So just click the "Advanced Settings" of your application pool and reset your "Identity".
我的情况是我的登录密码改变了,而应用程序池仍然使用旧的。因此,只需单击应用程序池的“高级设置”并重置您的“身份”。
回答by humbads
If you can run the website in Visual Studio debugger, then might be able to see where in your code the application pool is crashing. In my case, it was a function being called recursively an unlimited number of times, and that caused a stack overflow. Note: the Windows event log and the IIS logs were not helpful to diagnose the problem.
如果您可以在 Visual Studio 调试器中运行该网站,则可能能够看到应用程序池在您的代码中崩溃的位置。就我而言,它是一个被无限次递归调用的函数,这导致了堆栈溢出。注意:Windows 事件日志和 IIS 日志对诊断问题没有帮助。
回答by thd
I had a similar issue. I solved it by adding my user to the "Log on as a batch job" policy under "Local Security Policy" > "Local Policies" > "User Rights Assignment".
我有一个类似的问题。我通过将我的用户添加到“本地安全策略”>“本地策略”>“用户权限分配”下的“作为批处理作业登录”策略来解决它。
回答by Swapnil Kale
When I first time add the service and created the app pool for it. I did "iisreset" from command prompt, and it worked.
当我第一次添加服务并为其创建应用程序池时。我从命令提示符执行了“iisreset”,并且它起作用了。
回答by dantheman
In addition to the steps outlined at this link from Orhan's answer, you may need to additionally remove the native module by going to IIS Manager > Server Root > Modules > Configure Native Modules. Select MfeEngine and then select Remove.
除了此链接中 Orhan 的回答中概述的步骤之外,您可能还需要通过转到 IIS 管理器 > 服务器根目录 > 模块 > 配置本机模块来额外删除本机模块。选择 MfeEngine,然后选择删除。
回答by Miquel
I was experiencing this error and in my case the cause was that some time ago I modified the user password, and the 503 error didn't appears till I restarted the application pool.
我遇到了这个错误,在我的情况下,原因是前段时间我修改了用户密码,直到我重新启动应用程序池才出现 503 错误。
So I fixed it setting the new password on Applications Pools / Advanced Settings / Identity / [...] / Set... / Password / Confirm Password
所以我修复了它在应用程序池/高级设置/身份/[...]/设置.../密码/确认密码上设置新密码