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
144
votes
5 answers

Url.Action parameters?

In listing controller I have, public ActionResult GetByList(string name, string contact) { var NameCollection = Service.GetByName(name); var ContactCollection = Service.GetByContact(contact); return View(new…
user787788
  • 1,575
  • 2
  • 9
  • 6
99
votes
2 answers

Url.Action puts an & in my url, how can I solve this?

I want to send the variables itemId and entityModel to the ActionResult CreateNote: public ActionResult CreateNote( [ModelBinder(typeof(Models.JsonModelBinder))] NoteModel Model, string cmd, long? itemId, string modelEntity) with…
Niek de Klein
  • 8,524
  • 20
  • 72
  • 143
78
votes
4 answers

How to pass Area in Url.Action?

The problem in Html.ActionLink() is that you can't add additional html content inside the tag that it generates. For example, if you want to add an icon besides the text like: Go to…
doncadavona
  • 7,162
  • 9
  • 41
  • 54
28
votes
7 answers

How to use Url.Action() in a class file?

How can I use Url.Action() in a class file of MVC project? Like: namespace _3harf { public class myFunction { public static void CheckUserAdminPanelPermissionToAccess() { if…
Erçin Dedeoğlu
  • 4,950
  • 4
  • 49
  • 69
25
votes
3 answers

URL.Action includes id when constructing URL

I'm using ASP.Net MVC. Here's my code snippets from a controller named Course: public ActionResult List(int id) { var viewmodel.ShowUrl = Url.Action("Show", "Course"); ... } public ActionResult Show(int id) { ... } viewmodel.ShowUrl…
Tom Schreck
  • 5,177
  • 12
  • 68
  • 122
24
votes
8 answers

How to Open .pdf on a new Tab

The Objective: I have to print a PDF on a new tab after some tasks have finished correctly. Steps: I want to execute a method that should go to the server, take the PDF and open it on a new Tab, I was trying with these but is not…
user1520494
  • 1,134
  • 2
  • 11
  • 27
22
votes
3 answers

How to pass dynamic value in @Url.Action?

I have written following jquery in my partial view: $.ajax({ type: "POST", url: '@Url.Action("PostActionName", "ControllerName")', data: { Id: "01" }, success: function(data) { if…
Nirman
  • 6,715
  • 19
  • 72
  • 139
12
votes
1 answer

How does Url.Action work Asp.net MVC?

This is somewhat related to another question I've asked but I figure why not ask it seperately. If I were to place something like the following in a view
zSynopsis
  • 4,854
  • 21
  • 69
  • 106
11
votes
1 answer

@Url.Action adding "amp;" between parameters creating nulls in the controller?

I am trying to send through multiple parameters through the Url.Action. $('#dialog').dialog({ autoOpen: false, width: 850, height: 420, resizable: false, title: 'Vehicle details', modal: true, open: function (event, ui) { …
Pomster
  • 14,567
  • 55
  • 128
  • 204
8
votes
2 answers

How do I stop URL.Action from including parameters?

In my main navigation I have a link to: Url.Action("Items", "FAQ"); The link works fine and I get to ~/Item/FAQ However, I have links which contain parameters, so: ~/Items/FAQ/Question-1 This all works fine, however, when I'm viewing Question-1…
Jack Marchetti
  • 15,536
  • 14
  • 81
  • 117
7
votes
3 answers

Url.Action() includes unwanted parameters, trying to have more control

I have a link in a page that goes like this: Url.Action("List", "Item", new { category = "seasons" }) The Route that matches that page also has a parentGroup and group parameters Ex: /Seasons/Moober/Blue/1 ->…
Emanuel
  • 610
  • 6
  • 15
7
votes
1 answer

how may i add integer list to route

I'm trying to add int[] array to my Url.Action something like this: var routeData = new RouteValueDictionary(); for (int i = 0; i < Model.GroupsId.Length; i++) { routeData.Add("GroupsId[" + i + "]", Model.GroupsId[i]); } in my…
Sasha
  • 20,424
  • 9
  • 40
  • 57
7
votes
3 answers

call a partial view using @url.action click using jquery

call a partial view on @url.action. i am displaying the records using url.action and want to load the partial view when user click on the records. here is my code on which i want to call the partial view when user click on it.
Reshav
  • 545
  • 3
  • 9
  • 31
6
votes
2 answers

MVC3 unterminated string constant syntax error

I have the following code which gives me a syntax error - unterminated string constant.I've matched up the quotes can't seem to spot an issue. Any ideas? It works fine, the syntax error is just annoying.
newbie_86
  • 4,520
  • 17
  • 58
  • 89
1
2 3
9 10