WebDevGuy2
WebDevGuy2

Reputation: 1249

How change default url (remove subdirectory) for MVC application

Just deployed ASP.NET MVC5 web application to IIS 10. To do this, under "default website", I created a new application ("Add application"). I had to put in an alias so I put in "xyz".

So, now the public url is similar to http://xyz.mysite.com/xyz .... but I want it to be only http://xyz.mysite.com (remove 'xyz' subdirectory).

How can I do this?

The problem is that my ajax calls are failing because of the subdirectory.

Upvotes: 0

Views: 153

Answers (1)

kots
kots

Reputation: 465

You can do either of the following:

Option 1: Add Website in your IIS (instead of Add Application) and use the SNI feature. All relative path will be from root (/) level.

or

Option 2: Modify your AJAX calls to use @Url.Action("actionName", "controllerName") so your URLs will be generated properly based on relative path. I suspect you are hardcoding actionNames to "/controllerName/actionName" which uses root as your relative path.

Upvotes: 1

Related Questions