Banketeshvar Narayan

Banketeshvar Narayan

  • NA
  • 15.8k
  • 5.7m

IIS web hosting skipping website route path

Jun 20 2016 2:51 AM

I have created a website in MVC with AngularJS and it is working fine with IIS express but not with IIS 7.

While it is running from Visual studio it is using IIS express and running on some port like localhost:50504

When I am hosting it on IIS it is running as localhost/MyWebApp. When I am requesting the url http:// localhost/MyWebApp then it is working and opening the login page.

But after that it is redirecting to invalid path it is redirecting it to http://localhost/Home/Index where as it should redirect to http://localhost/MyWebApp/Home/Index.

On IISExprees it is redirecting to correct path i.e. localhost:50504/MyWebApp/Home/Index

I have hosted another ASP.NET Web API 2 site on same IIS server and it working fine. In case of Web API I am using Web API routing whereas in case of MVC Web Application relative path is written in angularJs controller file.

I have tried a. …/, b. ../../ & c. ~/ but it does not work for me.

I have done one more thing in Visual Studio

I change project URL http://localhost:54687 to http://localhost/MyWebApp from the web tab and created virtual directory after that it stops working from my local machine too i.e. redirecting after login to localhost/Home/Index where as it should redirect to http:// localhost/MyWebApp/Home/Index

when I am using

$window.location.href = $window.location.href + "/Home/Index"; then it is working fine but in that case I have to make changes on multiple places in javaScript and CSS because images and other paths also needs to be updated.

I am looking for standard solution that require minimal changes.


Answers (1)