0

I would like to add a virtual path to my asp.net application. In visual studio there is a setting virtual path I'd like to put a version number as the part of the url of my application.

It was like http://localhost:53278/{controller}/{action}

I would like to add an extension like this

http://localhost:53278/0.0.0.1/{controller}/{action}

Somewhere I need to configure in my asp.net mvc 3 application ?

Thanks

icn
  • 17,126
  • 39
  • 105
  • 141

2 Answers2

1

Are you trying to do this dynamically?

Areas can be used if that isn't desired, but in the end it represents a different route entry. That route entry can be dynamically added or hard coded.

When adding routes you can do something like

// used System.Reflection.Assembly.GetExecutingAssembly().GetName().Version to get the version then build the string you want

context.MapRoute(
                "Versioned_default",
                "<YOURVERSIONSTRING>/{controller}/{action}/{id}",
                new { action = "Index", controller = "Home", id = UrlParameter.Optional }
            );
Jared Peless
  • 1,120
  • 9
  • 11
  • Could you elaborate respectively hwo to implement this if dynamically or statically – icn Oct 26 '11 at 20:26
0

It's generally not a good idea to include periods in the url, other than for extensions. 0-0-0-1 would work. In visual studio, right click on the MVC project in solution explorer (the project, not the solution) and on the web page, if you're using the default development server, then just change the virtual path and save. Done.

If you're using IIS, you have to type in the path and click Create Virtual Path.

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
  • that is excatly what i did in visual studio (I changed virtual path to /0.0.0.1/), but it is not working – icn Oct 26 '11 at 19:48
  • @ error message i got " The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly." – icn Oct 26 '11 at 20:19