开发者

help resolve url in facade class or controller class

I have a facade class that my controller class calls out to and in that facade class, for whatever reason, I'm building a string a href element.

And it resolves fine in casini but when it gets out in the real开发者_如何学编程 world like localhost it doesn't work. Is there a way to do this?

string goBackLinkForErrorMessage = "<br /><a href='/MyController/Action?id=" + blah + "'>Go Back</a>";

Thanks, Rod.


I assume this is in a directory that is not the root? The / at the beginning of your URL is going to take the link to the root of the site. I would assume you need to put some logic at the front of the URL to build it correctly.

So something like this:

string goBackLinkForErrorMessage = "<br /><a href=" + Request.ApplicationPath.TrimEnd('/') + "'/MyController/Action?id=" + blah + "'>Go Back</a>";

You will want to keep the TrimEnd on the end of that Application Path for cases when it is the root.

A lot of this was made on assumptions because "it doesn't work" isn't real clear.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜