相关疑难解决方法(0)

IIS7自定义404没有显示

使用Intergrated .net 4.0应用程序池创建了一个新的IIS7网站.

以.aspx结尾的网址会显示自定义404其他任何内容都会显示蓝色服务器错误页面"HTTP错误404.0 - 未找到您要查找的资源已被删除,名称已更改或暂时不可用." (所以与IE无关)

<customErrors redirectMode="ResponseRewrite" mode="On" defaultRedirect="/pages/404.aspx" />
</system.web>
<system.webServer>
    <httpErrors  >
        <remove statusCode="404" subStatusCode="-1" />
        <error statusCode="404" prefixLanguageFilePath="" path="/pages/404.aspx" responseMode="ExecuteURL" />
    </httpErrors>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)

也试过了

<httpErrors existingResponse="PassThrough" />
Run Code Online (Sandbox Code Playgroud)

但这只是导致空洞的回应.

我只找到了一个对执行appcmd来测试自定义http错误处理的有用性的引用,但这里是结果.

C:\Windows\System32\inetsrv>appcmd list config "http://mysite/file.notexist" -section:httpErrors

<system.webServer>
    <httpErrors>
        <error statusCode="401" prefixLanguageFilePath="%SystemDrive%\inetpub\custer
r" path="401.htm" />
        <error statusCode="403" prefixLanguageFilePath="%SystemDrive%\inetpub\custer
r" path="403.htm" />
        <error statusCode="404" prefixLanguageFilePath="%SystemDrive%\inetpub\custer
r" path="404.htm" />
        <error statusCode="405" prefixLanguageFilePath="%SystemDrive%\inetpub\custer
r" path="405.htm" />
        <error statusCode="406" prefixLanguageFilePath="%SystemDrive%\inetpub\custer
r" path="406.htm" />
        <error statusCode="412" prefixLanguageFilePath="%SystemDrive%\inetpub\custer
r" path="412.htm" />
        <error statusCode="500" prefixLanguageFilePath="%SystemDrive%\inetpub\custer …
Run Code Online (Sandbox Code Playgroud)

.net iis-7 http-status-code-404

41
推荐指数
2
解决办法
3万
查看次数

错误404的默认重定向

我想在我的ASP.net网站上介绍一个功能,每当收到我域上未知URL的请求时,用户就会被重定向到error_404.htm应用程序根目录中的页面.

例如,如果请求是 http://www.mydomain.com/blahblahblah

然后,我希望它将请求重定向到,而不是返回标准的404错误页面 http://www.mydomain.com/error_404.htm

更新 IIS 7.5和.NET Framework版本4

更新 /blah.aspx重定向但/blah不重定向

asp.net redirect default http

27
推荐指数
1
解决办法
6万
查看次数

web.config没有转发到非.aspx页面上的404错误页面

目的

我希望所有丢失页面的URL都转发到我的根页中的404页面 404error.aspx

问题

到目前为止,只有具有.aspx遗嘱的网址才有效.例如,如果输入,4error.aspx您将被重定向到错误页面.

/404error.aspx?aspxerrorpath=/4error.aspx
Run Code Online (Sandbox Code Playgroud)

背景

我不是.NET开发人员,所以我接手了这个使用经典的项目.aspx.因此,我没有使用任何Microsoft产品在模板或框架中构建任何此类产品.我只是在Sublime文本编码.

我已经研究过的

我查看了许多我在Google上发现的文章,但没有任何实际工作的完整示例.

这是我开始使用的完整代码 web.config

web.config中

<configuration>
  <system.web>
    <customErrors mode="RemoteOnly" defaultRedirect="~/404error.aspx" />
      <globalization
        fileEncoding="utf-8"
        requestEncoding="utf-8"
        responseEncoding="utf-8"
        culture="en-US"
        uiCulture="de-DE"
      />
  </system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)

我也从微软发现了这个例子(404error.aspx是我的修改版)
http://msdn.microsoft.com/en-us/library/vstudio/bb397417%28v=vs.100%29.aspx

web.config(2)

<configuration>
  <appSettings/>
  <connectionStrings/>
  <system.web>
    <compilation debug="true" />

    <!-- Turn on Custom Errors -->
    <customErrors mode="On" 
      defaultRedirect="/404error.aspx">
      <error statusCode="404" redirect="/404Error.aspx"/>
    </customErrors>

  </system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)

这也没有处理没有的页面 .aspx

然后我尝试了这个例子

web.config(3)

<?xml version="1.0"?>
<configuration>
   <system.web>
    <customErrors mode="RemoteOnly" defaultRedirect="~/404error.aspx" />
    <error statusCode="404" …
Run Code Online (Sandbox Code Playgroud)

asp.net redirect web-config

12
推荐指数
1
解决办法
2万
查看次数