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 !

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

How about if I have "../Content/Images/myImage.gif" ?
That's folder-relative (.. = "go up one from here"), so it should work. Try it and see.
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

1 Comment

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
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.