0

I'm trying to show a complete URL with MVC 4 web application like: localhost:8888/index.aspx, i want to show the complete URL in the browser. I found similar questions here and in this answer: https://stackoverflow.com/a/8557085 They say that the file extension can be seen.

But when i change the routes objetc like this:

routes.MapRoute(
     name: "Default",
     url: "{controller}/{action}.aspx",
     defaults: new { controller = "PaymentPortal", action = "PaymentPortal", id = UrlParameter.Optional }
);

or

routes.MapRoute(
     name: "Default",
     url: "{controller}/{action}/{id}.aspx",
     defaults: new { controller = "PaymentPortal", action = "PaymentPortal", id = UrlParameter.Optional }
);

I get the next error: Error HTTP 403.14 - Forbidden

I try the next fixes, in the class RegisterRoutes i add the next line: routes.RouteExistingFiles = true;

In web.config i add, remove and change a few things like:

<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<modules runAllManagedModulesForAllRequests="true"/>

I play with the ExtensionlessUrlHandler adding, deleting and changing the tags and the values but nothing. I add the modules runAllManagedModulesForAllRequests="true" but nothing either.

I'm working with VS2012 in Windows 8, MVC 4 with ASPX engine. Any help would be appreciate, thank you very much!

P.D.: My apologies if i made some mistake with my english.

Community
  • 1
  • 1
xdrtas
  • 23
  • 4

1 Answers1

1

I've just made a new MVC 4 application and created the routes:

routes.MapRoute(
    name: "Test",
    url: "{controller}/{action}.aspx",
    defaults: new {controller = "Home", action = "Index"}
    );

routes.MapRoute(
    name: "TestId",
    url: "{controller}/{action}/{id}.aspx",
    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    );

routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);

And the these url work

http://localhost:62312/Home/index/123test.aspx
http://localhost:62312/Home/index.aspx

Remember the order in which you create routes is important as well.

matt_lethargic
  • 2,706
  • 1
  • 18
  • 33
  • Thank you @matt_lethargic, the problem comes because i was trying to modify the default instead of adding other routes, now is working. Now, I must see how to fix the paths of scripts in view page, because i'm get 404 error if i go to http://localhost:62312/Home/index.aspx instead of http://localhost:62312/ In http://localhost:62312/ the scripts are correctly loading. Wow, the thing was that i have to add other routes. Thank you for respond so quickly. – xdrtas Jun 05 '14 at 15:31
  • either use @Url.Content("~/scripts/somescript.js") in the src attribute or put the entire path in – matt_lethargic Jun 05 '14 at 15:34