12
I have a domain on a shared server and within it I have some subfolders that are set as applications on IIS 7. Within the main domain I created subdomains that redirect to applications/folders.
Ex:
- www.dominio.com.br
- Subdomain.dominio.com.br
It worked perfectly with an Asp.net Web Forms application. But I updated the technology to MVC and when I access the application by the url "Subdomain.dominio.com.br" MVC is adding the name of the subfolder/application to the url by clicking on a link action.
Ex:
- Subdomain.dominio.com.br/Domain/Controller/Acction
and so the application doesn’t work. only works if I access the application by the url: "www.dominio.host.com.br/App/Controller/Acction" and still have to change some requests in the code.
would like the url to appear only:
- Subdomain.dominio.com.br/Controller/Acction
I have tried several route options in the code and also tested Rewrite URL as below but nothing worked.
<system.webServer>
.
.
.
<rewrite>
<rules>
<rule name="Remove Virtual Directory">
<match url=".*" />
<action type="Rewrite" url="{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
Suggested Update
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
Have you checked if the directory where the MVC application is even as an application? If possible update your question with your routing rules (Registerroutes)
– Cleiton
Yes, the directory is as an application. I updated, but this is by default MVC
– Fesaro