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

2 Answers 2

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 }
            );
Sign up to request clarification or add additional context in comments.

1 Comment

Could you elaborate respectively hwo to implement this if dynamically or statically
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.

2 Comments

that is excatly what i did in visual studio (I changed virtual path to /0.0.0.1/), but it is not working
@ 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."

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.