Questions tagged [url.action]

In ASP.NET MVC the URLHelper provides a method called Action that generates a fully qualified URL to an action method by using the specified action name, controller name, route values, and protocol to use.

In ASP.NET MVC, Controllers and Views has a property called Url that exposes a URLHelper type, which help to create URL address.

The URLHelper provides a method called Action that generates a fully qualified URL to an action method by using the specified action name, controller name, route values, and protocol to use, for sample:

<a href="@Url.Action("Create", "Product", new { area = "Sales" })">New Product</a>

See de MSDN documentation.

143 questions
5
votes
2 answers

Only first parameter value is getting while calling controller method using Url.action.

I am calling a controller method using Url.action like, location.href = '@Url.Action("Display", "Customer", new { username = "abc",name = "abcdef",country = "India",email = "abc@hmail.com",phone = "9456974545"})'; My controller method is, public…
Kokila
  • 997
  • 3
  • 8
  • 14
4
votes
2 answers

Use Url.Action to generate fully qualified anchor

I'm using Url.Action to generate link in e-mails (with the Postal MVC Framework) that was sent by my application, however, the links generates are showing with "localhost" name, and not domain name. I'm using the following…
Dan
  • 1,518
  • 5
  • 20
  • 48
4
votes
2 answers

ASP.NET MVC: Application_Start and Url.Action

I am struggling with MVC - which I love - and it's features. I am trying to load a menu in the Application_Start event. I want to load some links with the correct url (controllerName/actionName) but I can't use the Url.Action or other methods to…
LeftyX
  • 35,328
  • 21
  • 132
  • 193
4
votes
1 answer

how to get javascript variable into URL.Action mvc method

onSelectRow: function(id) { document.location.href = '@Url.Action("EditEncounter", "EditEncounter", new { encounterId = "'<%:id%>'", popId = TempData["POPULATIONID"] })' //new { encounterId = temp.EncounterId, popId =…
SoftwareSavant
  • 9,467
  • 27
  • 121
  • 195
3
votes
2 answers

Problem by Url.Action in asp.net MVC

I have a problem by Url.Action in asp.net MVC. this is a sample: Url.Action("index", new { page = 1, success = 2}); This code generate this url index?page=1&success=2 In this url there is & instead of & character. because of this problem…
Ghooti Farangi
  • 19,926
  • 15
  • 46
  • 61
3
votes
3 answers

How to redirect from AREA's cshtml page to normal controller's ActionResult using @Url.Action?

How can I redirect to an ActionResult of a normal controller from .cshtml page of my Area's view? I have a common login screen for normal/admin user. So based on the usertype json result will return the user type. So now I want to redirect a user…
3
votes
3 answers

Client side value in URL.Action parameter

I am trying to post feedback on an object from a modal popup. No values on the popup are populated from server side.
2
votes
2 answers

How to format a URL.Action() call in JQuery to set a link's href attribute?

I need to set the href attribute of a link to point to a specific image, which has its id from the database set as its title. However, I am having trouble with trying to format the string to include a call to get the title attribute of the…
Anonymous
  • 57
  • 1
  • 5
2
votes
2 answers

ASP.NET Core Url.Action return empty string

After 3 hours browsing on stackoverflow I don't find solution of my problem. So I suspect something in my project is special. I have a ASP.NET Core (2.0) WebApplications Project on Visual Studios 2017. I try to make a ajax call from my…
Mar Tin
  • 2,132
  • 1
  • 26
  • 46
2
votes
3 answers

Rendering different content on partial views each time user clicks

I know how to render a partial view with jquery. Now, I am trying to render different content in the same div element each time the user click (using partial views). I have a method in my home controller public IActionResult Details(int x) …
Avan
  • 366
  • 3
  • 17
2
votes
0 answers

mvc Url.Action generating an argumentexception

I have a menu containing various links to specific pages in my app. One of them has just started exhibiting very strange behaviour. Heres the markup
  • proteus
    • 545
    • 2
    • 12
    • 36
  • 2
    votes
    0 answers

    URL generation with RazorEngine

    I'm currently using Razorengine to generate emails outside of asp.net. However I'm unable to use @url.action in my template as follows becuase the it's not part of Razor.
    adam78
    • 9,668
    • 24
    • 96
    • 207
    2
    votes
    3 answers

    How to append a querystring to the url created by Url.Action base on a hidden fields values

    Here is my controller Action method public ActionResult ChangeStateId(int userId,int stateId) { return RedirectToAction("Index") } and in my anchor tag of View, i want to redirect to above action method with parameter values like this
    Steve
    • 352
    • 2
    • 6
    • 24
    2
    votes
    1 answer

    Url.Action in controller generates port twice

    I am using below piece of code to generate a fully qualified url and pass it back as json for redirection. returnUrl = Url.Action("ActionName", "Controller", new RouteValueDictionary(new { type= returnUrl }), …
    Guruprasad J Rao
    • 29,410
    • 14
    • 101
    • 200
    2
    votes
    1 answer

    Pass a javascript variable as parameter to @url.Action()

    is it possible to pass a javascript variable as a parameter to @url.Action(), because as far as i know there may be server and client side issue, my requirement is i have to download the file according to filter, and ajax call doesnot work with…
    Teerth
    • 169
    • 3
    • 5
    • 19
    1
    2
    3
    9 10