Reputation: 429
Ok, this one has me stumped, been at it all day. I have an MVC5 app that can't find an .aspx page in a subfolder.
So I have an .aspx page here /Reports/page.aspx
and i've tried adding each of these route config additions based on various web searches
routes.Ignore("{resource}.aspx/{*pathinfo}");
routes.Ignore("Reports/{resource}.aspx/{*pathInfo}");
routes.IgnoreRoute("Reports/{*allaspx}", new { allaspx = @".*\.aspx(/.*)?" });
The problem i'm finding is that an .aspx file in the root of the site is found, but not my .aspx in the 'Reports' subfolder.
Even stranger, I can publish locally and point my local IIS7.5 at my published site and it routes to my .aspx files fine. Publishing to a remote server (shared hosting) I get 404's!
If anybody has any clue as to what might be the cause...an IIS config setting perhaps? ... i'd appreciate any help. I've literally googled ALL day and found nothing that's sorted it.
Thanks in advance...
Upvotes: 0
Views: 289
Reputation: 6814
Registering routes.Ignore and routes.IgnoreRoute is not required. aspx should work fine (and it seems it works within the root). Are you sure that there is no any rewriting rule or other route which is related to the /Reports folder? Is that happen to all folders? Try to create an empty aspx file or just put <%= Now %> and see if it works with other name or other folder.
Upvotes: 1
Reputation: 180
As smirnov mentioned in the comment, none of the routes.Ignore or routes.IgnoreRoute statements are needed for accessing .aspx files. However, you could be facing an issue that I also faced recently. So, I'll mention the scenario.
If you are using "Web.sitemap" file and you have entry for "filename.aspx" only, you'd face runtime errors accessing the sitemap entry for that page. The reason is, the MVC framework converts "/abc.aspx" request to "/abc". So, I had to use duplicate entries in the web.sitemap as following:
<siteMapNode url="Account/AddUser.aspx" title="Add New User" description="">
</siteMapNode>
<siteMapNode url="Account/AddUser" title="Add New User" description="">
</siteMapNode>
Of course, some elegant solution like "Routes.Ignore()" must be out there, but, my point is absence of those is not the reason of the inaccessibility of .aspx files.
Upvotes: 0