How do I refer to a constant URL in my route configuration?
- by Remnant
Suppose I have the following within a webpage
<% using (Html.BeginForm("ShowData", "Summary")) %>
<% { %>
<div class="dropdown"><%=Html.DropDownList("CourseSelection", Model.CourseList, new { @class = "dropdown", onchange="this.form.submit();" })%> </div>
<% } %>
When the user makes a selection from the dropdown the form is submitted and I would like it to link to another page with a URL as follows:
http://localhost:1721/Summary
I have the following routes:
routes.MapRoute(null, "Summary", new { controller = "Summary", action = "ShowData", CourseSelection = (string) null });
routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Login", action = "Index", id = UrlParameter.Optional });
When a user selects an item in the dropdownlist, the URL returned is:
http://localhost:1721/Summary/ShowData?CourseSelection = UserSelection
Clearly the first route in the list is not being matched.
I don't want the URL to show the action name and parameter. I simply want to show "Summary" which is what I have hard coded in the URL. How do I achieve this?