tags:

views:

22

answers:

1

Hi All,

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.

A: 

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.

Clarence Klopfstein