0

What I need is to generate the full url for one of my controllers inside a view (so that a user can copy it). For the following:

    [GET("invitationrequest/create")]
    public ActionResult Execute()
    {

I need to generate something like: http://xyz.com/invitationrequest/create

I've seen this answer: Getting full URL of action in ASP.NET MVC - it does the job, but only if the view and the controller have the same path. The problem is in my case, the view sits in a different location - let's call it http://xyz.com/mynetwork/generatelink

Community
  • 1
  • 1

1 Answers1

0

Ok, I've found out why it didn't work - the problem was with areas. If the controller is in a different area, this needs to be specified:

@Url.Action("About", "Home", new { area = ""}, Request.Url.Scheme)

In my case, the view was in MyNetwork area, and the controller wasn't inside an area at all - so I used empty string.

Got the answer thanks to this one: Url.Action doesnt work with non standard MVC Route

Community
  • 1
  • 1