0

right now i take the

 RequestContext 

and pass this into a UrlHelper like this:

UrlHelper u = new UrlHelper(context);
string hrSyncUrl = u.Action("Update", "Person");

but the issue is that this seems to return:

/Person/Update

instead of:

http://www.mysite.com/Person/Update

so, given a controller and and action name, how can i generate a FULL url from inside a controller?

the reason that i need this is that i am generating an email so i need the full url to put in the body of that email.

2
  • What are you hoping to use it for? Commented Apr 26, 2011 at 18:02
  • @R0MANARMY - i updated the question, i need to put a url into an email and "/Person/Update" doesn't really work ? Commented Apr 26, 2011 at 18:02

2 Answers 2

3

By using the proper overload:

string hrSyncUrl = u.Action("Update", "Person", null, "http");

And to avoid hardcoding the protocol you could fetch it from the request:

var protocol = context.HttpContext.Request.Url.Scheme;
string hrSyncUrl = u.Action("Update", "Person", null, protocol);
Sign up to request clarification or add additional context in comments.

Comments

0

see ASP.NET MVC create absolute url from c# code

Comments

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.