c# - ActionLink doesn't make correct with URL, but RouteLink does with attribute routing -


Sometimes I ActionLink refuses to create the correct URL with placeholders in my application, But when I specify the name on the root attribute, it generates the url properties.

This is my most recent move, with this:

  [RoutePrefix ("RuleConfiguration")] Public class RuleConfigurationController: EntityController & LT; RuleConfigurationModel, RuleConfiguration & gt; {// ... snip ... [Route ("{configurationId} / edit", name = "Rule configuration edit")] Public ASICNC work and lieutenant; Actionsclass & gt; Edit (int configured) {return view (...); } // Setup ...}   

Looking at this setup, I expect ActionLink , when used like this:

  @ html.ActionLink (name, "edit", "rule configuration", new {configurationId = conf.Id})   

me / RuleConfiguration / 1 / edit . However, I just get the / rule configuration when using the as RouteLink then:

  @ Html.RouteLink (conf.Name , "RuleConfigurationEdit", new {configurationId = conf.Id})   

This produces the expected URL. On this same scene, I have a link to another action with a ActionLink , and it does generate one with the expected action name. One difference is that in this other verb, any path parameter is not.

I have checked (many times) that the parameters near me are correct, and the ActionLink spelling is correct, and matches the URL parameter which expects the function . Name parameter was added to ActionLink before working

RouteLink will work >

is starting with the first viewing snippet:

  @ Html.ActionLink (name, "edit "RuleConfiguration", new {configurationId = conf.Id})   

This slice uses the overload of the method:

  public static MvcHtmlString ActionLink (HtmlHelper HtmlHelper, String LinkText, String actionName, Object routeValues, Object htmlAttributes)   

The following H The result in TML is:

  & lt; A configuration = "1" href = "" & gt; Will happen & lt; / A & gt;   

Configure IID is added to the attribute element because the last parameter is htmlAttributes parameter.

I found that if the current request has been done through the rule configuration controller , then to do the right thing (by using overload) Em> seems to:

  @ Html.ActionLink (name, "edit", new {configurationId = 1})   

This results in the following HTML:

  & lt; A href = "/ Rule Configuration / 1 / Edit" & gt; Fuga & lt; / A & gt;   

However, it does not seem to work while trying to take any action in a separate controller.


To use surcharges with those standards, which you intended to provide, use one:

  public Fixed MvcHtmlString ActionLink (this HtmlHelper HtmlHelper, string LinkText, string actionName, string controllerName, object pathValues, object htmlAttributes)   

If you are not using it, Code> null is OK to pass

  @ Html.ActionLink (name, "edit", "RuleConfiguration", new {configurationId = conf.Id }, Tap)   

This, The expected anchor produces the element and because the name of the controller is specified, it also works while referring to a controller through which the current request was not routed.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -