开发者

ASP.NET MVC3 app - HTTP Error 404.7 for route with double dot

Routing:

        context.MapRoute(
            "Dashboard_default",
            "Dashboard/{controller}/{action}/{jobName}",
            new { action = "Index", controller = "Dashboard"开发者_JS百科, jobName = UrlParameter.Optional }
        );

But for Route

http://localhost/candidate/Dashboard/Overview/Show/sdfdsf.xx.dd

I recieve:

HTTP Error 404.7 - Not Found The request filtering module is configured to deny the file extension.

In the same time, route

http://localhost/candidate/Dashboard/Overview/Show/sdfdsf.xx

Gives right response.

I assume some issue with IIS, have anyone seen that before?


To allow that particular url, in your web.config you could add this:

<system.webServer>
    <security>
      <requestFiltering>
        <fileExtensions>
          <remove fileExtension=".dd" />
        </fileExtensions>
      </requestFiltering>
    </security>
  </system.webServer>

Otherwise, you could add a <clear /> inside of fileExtensions to allow any file to be routed.


If you're using .Net 4.0, give this a shot in your system.web section of your web.config:

<httpRuntime relaxedUrlToFileSystemMapping="true" />

More explanation here: http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx

More info: http://weblogs.asp.net/carldacosta/archive/2010/04/24/tweaking-a-few-url-validation-settings-on-asp-net-v4-0.aspx

As I understand it, dots are treated as a literals in the routing definition.

http://haacked.com/archive/2008/04/10/upcoming-changes-in-routing.aspx


You need a catch all on the last param for the routing to work.

context.MapRoute(
            "Dashboard_default",
            "candidate/Dashboard/{controller}/{action}/{*jobName}",
            new { action = "Index", 
                            controller = "Overview", 
                            jobName = UrlParameter.Optional}
        );


.dd extension is one of denied file name extensions by default in IIS. You can remove it by going to inetmgr -> web site -> application (candidate) -> Request Filtering (in IIS section) -> find .dd under File Name Extensions tab and remove it.

EDIT

Described action will automatically add next section to web.config (I see that someone did that and posted it as new answer):

<system.webServer>
    <security>
        <requestFiltering>
            <fileExtensions>
                <remove fileExtension=".dd" />
            </fileExtensions>
        </requestFiltering>
    </security>
</system.webServer>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜