1

the current application on MVC can be accessed through URL Like: www.someserver.com/myapplication

Now there is a request to change it to a new URL: www.someserver.com/NEWFOLDER/myapplication

so my question is how will the MVC behave, will I have to make any routing changes ?

Thanks !

JackMith
  • 45
  • 5

3 Answers3

5

If your links are application-relative, for instance

<a href="@Url.Content("~/myAreaName/index/")">My Area</a>

then you shouldn't have any problems.

If you've used site-relative links,

<a href="/myAreaName/index/">My Area</a>

They'll break.

3Dave
  • 28,657
  • 18
  • 88
  • 151
2

@David has the correct solution. I also keep the URL in the config file as an app setting for use in certain situations.

<%: ConfigurationManager.AppSettings["WebsiteURL"] %>/Content/Images/a.png
Dustin Laine
  • 37,935
  • 10
  • 86
  • 125
  • Earlier we had it in the config..but then we changed. It is now myVirtualDirectory = String.Concat(lProtocolName + HttpContext.Current.Request.ServerVariables("SERVER_NAME"), HttpContext.Current.Request.ApplicationPath, "/")..... I hope works – JackMith Jun 23 '11 at 18:04
0

You shouldn't as long as your application root moves (i.e. in IIS) and your URLs all properly specified in helper methods, prefixed with "~" where appropriate.

For example, a URL in an MVC app that is specified like "~/images/foo.jpg" will resolve to "www.someserver.com/images/foo.jpg" in your current scheme. Under the new scheme, if properly re-rooted in IIS, it will resolve to "www.someserver.com/NEWFOLDER/images/foo.jpg".

If you've used absolute or strictly relative URLs, however, you may be out of luck.

Peter Meyer
  • 25,711
  • 1
  • 34
  • 53