Note that there are some explanatory texts on larger screens.

plurals
  1. POSending mail address as parameter in MVC5 causes site crash
    text
    copied!<p>I have been following this tutorial on <a href="http://www.codeproject.com/Articles/682113/Extending-Identity-Accounts-and-Implementing-Role?msg=4719497#xx4719497xx" rel="nofollow noreferrer">Extending Identity Accounts and Implementing Roles</a>. I didn´t implement some Delete methods I don´t need and I set ApplicationUser.userName attribute to be an email address. Those are restrictions of my project.</p> <p>Everything is working fine except user edition and role assignation. </p> <p>Once I load the Index of the AccountController Myhost/Account it shows this</p> <p><img src="https://i.stack.imgur.com/nKV1Z.png" alt="http://local:17353/Account "></p> <p>But Whenever I try to click on Edit or Roles links, it crashes weirdly, like this. Myhost/Account/Edit/username%40gmail.com</p> <p><img src="https://i.stack.imgur.com/462GC.png" alt="Myhost/Account/Edit/username%40gmail.com"></p> <p>I just realize this system is in spanish so I translate the error here. Error HTTP 404.0 - Not FOund The resource you look for has been removed, it name changed or is not available right now.</p> <p>Causes Specified Directory or file is not on the server url address has type error A filter, customized module, as URLScan, restricts file access</p> <p>What you can try Create content on the web server Check url on the browser Check registry of erroneous calls to see which module calls SetStatus. To get more information click here (<a href="http://go.microsoft.com/fwlink/?LinkID=66439" rel="nofollow noreferrer">http://go.microsoft.com/fwlink/?LinkID=66439</a>)</p> <p>Error detiled information</p> <p>I´ll just put the labels.</p> <p>Module Notification controller. StatisFile (this is not a controller in my website) error code requested url physic access route session start method session start user Calls Directory</p> <p>end of error</p> <p>However, the problem is on the urland is caused by the @ symbol in the url. If I rewrite the url as Myhost/Account/Edit?username=username%40gmail.com the edit form is loaded correctly.</p> <p><img src="https://i.stack.imgur.com/AYDVA.png" alt="enter image description here"></p> <p>How can I force the parameter to go as a querystring parameter? or, is there a way to make theserver understand the mail address in the standard way?</p> <p>The method invoked is this</p> <pre><code>[Authorize(Roles = "Admin")] public ActionResult Edit(string userName, ManageMessageId? Message = null) { var db = new ApplicationDbContext(); var user = db.Users.First(u =&gt; u.UserName == userName); var model = new EditUserViewModel(user); ViewBag.MessageId = Message; return View(model); } </code></pre> <p>UPDATE As you asked in the comments, here is the Index View</p> <pre><code>@model IEnumerable&lt;CAEWebSite.Models.EditUserViewModel&gt; @{ ViewBag.Title = "Index"; } &lt;h2&gt;Usuarios&lt;/h2&gt; &lt;p&gt; @Html.ActionLink("Nuevo usuario", "Register") &lt;/p&gt; &lt;table class="table"&gt; &lt;tr&gt; &lt;th&gt; @Html.DisplayNameFor(model =&gt; model.UserName) &lt;/th&gt; &lt;th&gt; @Html.DisplayNameFor(model =&gt; model.FirstName) &lt;/th&gt; &lt;th&gt; @Html.DisplayNameFor(model =&gt; model.MiddleName) &lt;/th&gt; &lt;th&gt; @Html.DisplayNameFor(model =&gt; model.LastName) &lt;/th&gt; &lt;th&gt; @Html.DisplayNameFor(model =&gt; model.SecondLastName) &lt;/th&gt; &lt;th&gt; @Html.DisplayNameFor(model =&gt; model.Email) &lt;/th&gt; &lt;th&gt;&lt;/th&gt; &lt;/tr&gt; @foreach (var item in Model) { &lt;tr&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.UserName) &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.FirstName) &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.MiddleName) &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.LastName) &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.SecondLastName) &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.Email) &lt;/td&gt; &lt;td&gt; @Html.ActionLink("Editar", "Edit", new { id = item.UserName }) | @Html.ActionLink("Roles", "UserRoles", new { id = item.UserName }) | @*@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })*@ &lt;/td&gt; &lt;/tr&gt; } &lt;/table&gt; </code></pre> <p><strong>UPDATE 2</strong></p> <p>This is my RouteConfig class, pretty much as VS generated it</p> <pre><code>public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload