English 中文(简体)
How to ASP. NET MVC3 接受任何类型的档案的路线(URL中的编号)
原标题:How to ASP.NET MVC3 Route to accept any type of file (Dot in URL)

ASP.NET MVC 2 Issue - Dot in Route gives an example to allow dot (.) in url and allow .svc file.

我的问题是,如何在任何类型的文件上,我尝试:

<httpRuntime relaxedUrlToFileSystemMapping="true" />
<remove extension=".*"/>

不工作! 我想的是:对于任何类型的URL(任何果园)来说,可由MVC3航道(MapRoute)处理。

最佳回答

here is the solution:

第一:如果你访问<代码>/web.config,NOT将造成安全泄漏。

HTTP Error 404.8 - Not Found
The request filtering module is configured to deny a path in the URL that contains a hiddenSegment section.

Unless you change the hiddenSegment of course.

这里的解决办法是web.config。 档案:

<system.webServer>
    <handlers>
        <add name="Static-Favicon" path="favicon.ico" verb="GET" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
        <add name="Static-Robot" path="robots.txt" verb="GET" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
        <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%Microsoft.NETFrameworkv4.0.30319aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
        <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%Microsoft.NETFramework64v4.0.30319aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
        <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*" verb="GET,HEAD,POST,DEBUG" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
</system.webServer>

如果你像MVC公司一样处理这两个档案,可以删除Static-Favicon和Static-Robot。

Btw, 您仍然需要<remove extension=“svc”/>处理vc文档;relaxedUrl ToFileSystemMapping 用于urll

问题回答

这是一种非常坏的想法。 你们希望人们能够下载你的网络。 见你的密码? 下载贵国数据库? 国际空间法学会和英国广播公司故意阻止许多延期,因为没有这样做,就非常不安全。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!