开发者

Combining a base uri to an MVC action and controller

开发者 https://www.devze.com 2023-02-08 16:20 出处:网络
I am developing an MVC application and I want to combine my Application url to a controller and action and instead of using string.Format etc i decided to get all fancy and use Uri functions like

I am developing an MVC application and I want to combine my Application url to a controller and action and instead of using string.Format etc i decided to get all fancy and use Uri functions like

Uri.TryCreate(baseUri, relativeUrl, out newUri)

Now my base uri is http:.//localhost/abc/web and my relative url is "NerdDinner/Invite"

now the new uri t开发者_Go百科hat is given out is http:.//localhost/abc/NerdDinner/Invite

where as I am looking for http:.//localhost/abc/Web/NerdDinner/Invite.

Please note adding a trailing '/' to the base url is not an idea that i am looking for which works btw.

Can someone help me with the same. Please note I dont have access to Url.Action etc.


Not to be pithy, but if adding a trailing slash works, why is that not an acceptable solution?


Have you tried using Url.Action(Action, Controller) method? e.g.

<%=Url.Action("Invite","NerdDinner")%>
0

精彩评论

暂无评论...
验证码 换一张
取 消