1

In short, I have an MVC web app that has a proxy class to marshall requests to another web app under the context of the logged in user.

This all works fine except that some of the outgoing links (i.e. inbound links to my MVC app) from the other web app contain the url "/views".

These requests should be mapped according to this route:

        routes.MapRoute(
            name: "TableauViews",
            url: "views",
            defaults: new { controller = "Tableau", action = "Views" }
        );

But it never happens. If I change the name of the controller action to something else and enter the corresponding url in a browser, it works.

This leads me to suspect that there is some problem mapping a url containing the word "views" as part of its path. Can anyone confirm this?

3
  • Could you post one full link, please? I bet it's not only /view, right? Commented May 17, 2013 at 19:17
  • I can imagine ~/views not working but ~/mycontroller/views I would expect to work? Commented May 17, 2013 at 19:41
  • ~/views doesn't work but I would expect it too as I have the route mapped as per the OP. If I change the name of the action method (and the route url) to something else e.g. views2 then the aqction method is invoked when I navigate to /views2 in a browser. And yes, ~/controller/views does work as it uses the default route. Commented May 20, 2013 at 8:33

2 Answers 2

1

The issue is the order of operations. Views is a physical folder and a route. The ASP.NET HttpHandler will read the web.config and block anything going to views before the route handler picks up the URL. If you look at the web.config file in your views folder (where your views are actually stored) you will likely see something like this:

<httpHandlers>
    <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>

Also, later in the config there may also be this:

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />

    <handlers>
        <remove name="BlockViewHandler"/>
        <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
    </handlers>
</system.webServer>

This is your culprit. I would suggest either naming your route something more like "externalViews" or simply "external" might help. The other alternative is to remove the line above from your views web.config, but this could result in some undesirable behavior.

This article deals with restricting only certain types of files from being delivered instead of blocking all that may be helpful for you.

http://blog.falafel.com/Blogs/j-tower/2014/03/28/loading-javascript-files-from-the-views-folder-in-asp-net-mvc

0
1

I couldn't find anything specifically saying "views" is a reserved word, but the article http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx describes how to relax the rules on what words can be used.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.