2

I am using WebAPI 2 with Attribute routing in my project. I deployed my project under a virtual directory in IIS. I need to remove virtual Directory name from the URL. Now my URL is api.mydomain.com/virtualdirectory/{controllerName}/{Version} In my Route Prefix I am passing controllerName/Version. I need to change the URL to api.mydomain.com/{controllerName}/{Version} Please help me how can i achieve this using attribute routing.

1 Answer 1

2

The question is will a request like api.mydomain.com/{controllerName}/{Version} hit your action?...route templates(with conventional or attribute routing) are always relative to the base path of your application and if the base path of the application includes the virtual directory, then the request urls would need to have this information to hit the actions...one option i can think of is to host your application directly under the website...

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

3 Comments

My Application should go under the virtual directory. For some of the controllers I need to rename the virtual directory name with the controller name.
I have the same requirement, & I'm experiencing the same problem - googling all I can to find a way to make it work (my search led me here)
@Kiran Please do you think you could help me with this question stackoverflow.com/questions/26835211/…

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.