ASP.NET/IIS:404所有文件类型 [英] ASP.NET/IIS: 404 for all file types

查看:93
本文介绍了ASP.NET/IIS:404所有文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设立了404页的处理程序在web.config中,但它的工作原理,只有当URL的扩展名的.aspx(或其他它是由ASP.NET处理)。
我知道我可以设置静态的HTML页面,网站的选择,但我希望有一个页面。
是否有任何选择指定ASPX页面的处理程序在IIS的所有要求扩展?

I set up 404 handler page in web.config, but it works ONLY when extension of URL is .aspx (or other which is handled by ASP.NET). I know I can setup static HTML page in website options, but I want to have a page. Is there any options to assign ASPX handler page for all request extensions in IIS?

推荐答案

的直接问题是,是否存在未选择指定的ASPX处理所有要求扩展:是的,有。我将讨论如何在短期内做的。

The direct question was whether or not there are options to assign the ASPX handler to all request extensions: Yes, there is. I'll discuss how to do that shortly.

首先,我觉得隐藏的问题 - 你真的想要的答案 - 是,是否有重定向所有的404错误比ASPX,ASMX等其他网页的方式对了,还有,这是在更好的选择,如果它会解决您遇到的问题。

First, I think the "hidden" question -- the answer you really want -- is whether or not there's a way to redirect all 404 errors for pages other than ASPX, ASMX, etc. Yes, there is, and this is the better choice if it'll solve the issue you're having.

要重定向所有404在IIS 6,右键点击你的Web应用程序根目录(无论是其自己的网站或在主站点的虚拟目录),并选择属性。从那里,选择自定义错误选项卡。在列表中找到404和其更改为你想要的重定向。

To redirect all 404s in IIS 6, right click your web application root (whether it be its own site or a virtual directory in the main site), and choose "Properties." From there, choose the "Custom Errors" tab. Find 404 in the list and change it to the redirect you want.

现在,如果这是不够的 - 我真的希望它 - 是的,你可以通过ASPX处理器运行的每一页。但是,这样做涉及在效率方面相当高的成本 - 原始的HTML /图像份量相当快于任何动态

Now, if that won't suffice -- and I really hope it does -- yes, you can run every page through the ASPX handler. However, doing so comes at a fairly high cost in terms of efficiency -- raw HTML/image serving is considerably faster than anything dynamic.

要做到这一点,右键点击你的Web应用程序根目录,然后选择属性。选择主目录选项卡。点击配置;一个新的窗口会弹出。路径从ASP.NET页面提供的一个副本,然后将其用于通配符应用程序映射。

To do this, right click your web application root and choose "Properties." Choose the "Home Directory" tab. Click "Configuration;" a new window will pop up. Copy the path from one of the ASP.NET page serves, and then use it for a wildcard application map.

记住,同样,这是在错误答案的大部分时间。它会将你的性能产生负面影响,而且是用电锯雕刻火鸡的等价物。我极力推荐的第一个选项了这一个,如果将制定出适合你。

Bear in mind, again, this is the wrong answer most of the time. It will negatively impact your performance, and is the equivalent of using a chainsaw to carve a turkey. I highly recommend the first option over this one, if it will work out for you.

这篇关于ASP.NET/IIS:404所有文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆