MVC :: Routing Is Correct, But Parameters Don't Reach The Action Method.

Jul 1, 2010

I've been struggling for some time now with an MVC routing issue, but I have finally reached a point where the basic routing is correct; that is, the application is invoking the correct action method and .aspx page, but the action method fails because no parameters are passed to it.

Before I show detailed screenshots of the problem, I had better provide some background. This is a bibliographic application which, among other things, analyzes text abstracts to identify unique words and the number of occurrences for each word in each document. This data will eventually be inserted into a SQL Server database, but for the time being I only want to do the calculation and display the results, on a document-by-document basis, in an .ASPX view set up for the purpose. The data structure of the application is as follows:

Collections -this is a set of fifty or so CollectionDetails items.CollectionDetails represent individual documents, in this case books in an academic library. Attributes of the CollectionDetail record are those typical of a library book--author, call number, title, year, and so on. The title and subject catalog headings are combined to form a quasi-abstract, which becomes the basis of the text analysis. In a few cases, I added additional text from Google Books or Amazon synopses and reviews.

MasterStopList contains common words such as pronouns and prepositions that we want to exclude from consideration.

View 8 Replies

Similar Messages:

Calling Action Method In MVC With JQuery And Parameters Not Working

Dec 27, 2010

I'm trying to call an action method in an MVC application using jQuery. Basically what I want is to take the value of a couple of input fields and call the action method by clicking a button, passing the values of the input fields as parameters. But I only get the value of the "number" parameter, not the "year" parameter.

function selectWeek() {
$('#selectWeekButton').click(function (event) {
var number = $("#selectWeekId").val();

I checked the url with an alert, as you can see, and it seems to contain both values fine. But when I check the value of the year parameter in the action method it is null.Here are the input fields:

<span>Vecka: </span>
<input type="text" id="selectWeekId" />
<span>År: </span>
<input type="text" id="selectYearId" />
<input type="button" value="Välj vecka" id="selectWeekButton" />

And the beginning of the action method:

public ActionResult Edit(string number, string year)

I know that this looks like a strange thing to do instead of just binding fields, but the reason is that these input fields and their values is not the main purpose of this View. They're just there to select another week in this timesheet application. And besides, I'm going to replace the input fields with a jQuery calendar eventually, so I will still have to do something like this.

So what's the easiest way to do this, and why isn't it working as it is?

View 2 Replies

MVC :: Making An Html Button Call An Action Method With Parameters?

Mar 10, 2011

how to make a stadard HTML button call an action method and pass parameters to it? Can you please show me an example of how to do this? THis is the method:

public ActionResult CCDReview([DefaultValue(1) int CUrrentPage])
//method code is here.

Yes, my button is wrapped in a form, and it's a "submit" button.

View 9 Replies

C# - Raise An Event Once When Reach End Of Method?

Jul 1, 2010

How to raise combobox_SelectedIndexChanged(object sender, EventArgs e) programmatically? Lets say i have method called ClearFields(). I want to call the event before i hit the end of Clearfields() method.

View 4 Replies

MVC :: Action Method Returning An ActionResult Used In A Action Method?

Aug 27, 2010

I have the Index action method calling a method that itself is an action method.

Example :


What to do in this case ?

View 10 Replies

How To Pass Parameters To An Action Using Html.Action() In MVC?

Jun 30, 2010

I've been using Html.Action("ActionName", "ControllerName") to invoke child actions across controllers without needing to have the view in ViewsShared. This has been working great for displaying things like session or cookie information.

Instead of just accessing cookies, I would like to pass additional parameters to Html.Action("ActionName", "ControllerName") so the action can execute different code based on the the data passed to the original view.

Should I be using a different method to pass parameters to a child action in a different controller?

View 1 Replies

MVC :: Can't Reach Controller - Javascript Library And Method Called From View

Jul 23, 2010

I have a javascript library and in there i have a method that is called from my view. Here it is:

<li><a href="javascript:void 0" onclick="deleteAll('image', '<%= ViewData["FileGroupId"]%>')"><div><%=GetGlobalResourceObject("default", "Delete_all") %></div><div></div></a></li>
and here is my js code in the javascript library:
var deleteAll = function(module, groupId) {
jConfirm(_deleteConfirmAll, _deleteAll, function(r) {
if (r) {
cache: false,
type: "POST",
url: _baseUrl + "/" + module + "/deleteall/" + groupId,
success: function(msg) {
if (msg == '0') {
location.href = _baseUrl + '/' + module;
else {
jAlert(msg, _errorTitle);
My problem is that i cant reach my controller. Here is my controller code:
#region common methods
List<.CMS.Core.File> GetList(int groupId)
List<CMS.Core.File> list = new List<CMS.Core.File>();
CMS.Core.FileFilter filter = new CMS.Core.FileFilter();
filter.GroupId = groupId;
int res = CMS.Core.File.Search(_connection, filter, ref list);
return list;
public ActionResult DeleteAll(int groupId)
List<CMS.Core.File> list = GetList(groupId);
foreach (File item in list)
return Json(list);
And at last her is my Index method
public ActionResult Index(int? id)
if (Request.IsAjaxRequest())
JsonPaging paging = new JsonPaging();
int offset = 0;
int page = 0;
if (!String.IsNullOrEmpty(Request.QueryString["page"]))
Int32.TryParse(Request.QueryString["page"], out page);
if (page > 0)
offset = (page * paging.PageSize) - paging.PageSize;
FileFilter filter = new FileFilter();
filter.Deleted = false;
filter.MaxRecords = paging.PageSize;
filter.Offset = offset;
if (!String.IsNullOrEmpty(Request.QueryString["keywords"]))
filter.FilterType = FilterTypes.AND;
filter.Name = Request.QueryString["keywords"].ToString();
if (!String.IsNullOrEmpty(Request.QueryString["sort"]))
filter.OrderBy = Request.QueryString["sort"].ToString();
if (!String.IsNullOrEmpty(Request.QueryString["direction"]))
filter.OrderBy = filter.OrderBy + " " + Request.QueryString["direction"].ToString();
if (id > 0)
filter.GroupId = id.Value;
List<CMS.Core.File> items = new List<CMS.Core.File>();
int results = CMS.Core.File.Search(_connection, filter, ref items);
foreach (CMS.Core.File current in items)
JsonItem item = new JsonItem();
item.Id = current.Id;
item.Name = current.Name;
item.ImageText = current.ImageText;
item.Aperture = current.Aperture;
item.TakenOn = current.TakenOn;
item.Camera = current.Camera;
item.ExposureTime = current.ExposureTime;
item.FocalLenght = current.FocalLenght;
item.Tags = current.Tags;
item.Url = current.Url;
item["Active"] = current.Active.ToString();
item["Created"] = current.Created.ToString();
return Json(paging, JsonRequestBehavior.AllowGet);
ViewData["FileGroupId"] = id;
return View();

View 2 Replies

MVC :: Redirect Action Not Working In Jqgrid Action Results Method

Mar 23, 2011

I am desiging a master and details page from a search page..user can search for something and I need to display the result in jqgrid if the result has more than 1 row or record.. if the result is just one record then i have to directly send then to details page by skiping grid page... I do have an action method for results page and one more action method for Jqgrid data..i am trying to check the row count for the database result and trying to redirect to details action results..but its not working at all..and showing an empty jqgrid..


View 9 Replies

MVC :: Routing For Same Action Names?

Feb 14, 2011

I am having trouble with adding routes to Global.asax for actions with same names.

For example, my controller has the 3 Action methods

public ActionResult GetMedia()

View 8 Replies

Routing In Web Forms / Input String Was Not In A Correct Format Exception?

Jan 22, 2011

I'm using Routing in web forms I try to use Page.RouteData.Values["Id"]; its a string I need the Id for a querys and for navigation so I've tried

object departIdString = Page.RouteData.Values["Id"];
string d = (string)departIdString;[code]...

at System.Convert.ToInt32(Object value)I've run out of ways to try the funny thing is it all works I get the Id out of the RouteData and hit The data base just fineit works all through the app. but it will fill up an elmah error log right quick and I don't think it should happen

View 5 Replies

MVC :: MVC3 RC2 Bug Binding From Request Parameters To Method Parameters?

Dec 10, 2010

Since ASP.NET MVC3 RC2 I encounter a bug when posting values to a controller method of which one of the parameter is a nullable int. Steps to reproduce:

I've created a test method


In MVC3 RC1 this was working without any problems with the nullable int

I don't seem to have the problem with a newly created MVC3 website. What could I have in my project that influence model binding to nullable int's? And why would there be a difference between RC1 and RC2?

View 10 Replies

MVC 2 Bug In Routing And Parameters?

Jul 12, 2010

I consider the following an error, and not a feature:

When posting a request, any parameters are held in the HttpContext.Request.Form as key/value pairs. This is perfectly fine for the recipient of the request. Unfortunately, however, further down the chain these values still exist and take precedent in binding over new parameters created during processing.

This is obvious in the RenderAction scenario. If a new parameter is created in a view and passed through RenderAction, if the parameter has the same name as one of the initial request parameters (or a form field for that matter), then MVC Binding will bind the initial request form value to the Action being called, and not the new parameter being defined in the RenderAction call. What's even more frustrating, is there is no easy way to override the initial form values.

It really does not make sense that a value defined in one context, should live throughout the entire processing context... at least without the developer being able to determine it should remain. At a minimum, any new parameter defined in the process with the same name should either a) be received as a parameter and not a form value; or b) override the form value.

View 5 Replies

Search Page MVC Routing (hidden Action, No Slashes, Like SO)?

Feb 22, 2011

I want my searches like those in Stack Overflow (i.e. no action, no slashes): --> goes to a general search page --> goes to actual search results

My routes:

The search results route does not work. I don't want to use the ".../..." approach that everyone seems to be using, because a search query is not a resource, so I want the data in a query string as I've indicated, without slashes--exactly like SO does.

View 1 Replies

MVC :: Routing - How To Get URL Parameters With Regex

May 27, 2010

I would like to be able to type in a URL like [URL] arrive at a Details Page which parsed the "M" and the "123" from the query string and used them as params to query a Table in my Database. I've been reading my @$$ off and I can't find anything close :>

View 3 Replies

Routing With Parameters In .NET Application?

Oct 7, 2010

I need to use routing with parameters in my ASP.NET application.

public class Global : System.Web.HttpApplication
void Application_Start(object sender, EventArgs e)

Then, by navigating to "/Profile" I want to get on Page_Load method Request.Params["Id"] as null and by navigating to "/Profile/1", Request.Params["Id"] as "1".

View 1 Replies

4.0 URL Routing With Two Or Multiple Querystring Parameters

Aug 16, 2010

How can I pass two querysting parameters in URL routing using ASP.NET 4.0? I have gone through many articles, but everywhere it shows only one parameter. I'd like the display URL to be: [URL] The first parameter is ID: 1 The second is Name: This is my first report I am trying following route, but it is not working

"MarketReports", // Route name
"Reports/{*i}-{*n}", // Route URL
"~/pageControl2.aspx" // Web page to handle route

How can I make this work as described?

View 1 Replies

.net MVC Routing To Controller With Optional Parameters

Apr 9, 2010

I have a controller method that is called with many different combinations of URL's. To overcome issue i am using optional is my controller method signature...public ActionResult localMembersSearch(string Gender, string calling, [Optional]string Region, [Optional]string County, [Optional]string Town, [Optional]string queryvalues)the first two parameters are not optional but always expect

View 1 Replies

.net Webforms Routing Optional Parameters

Sep 23, 2010

I want to add optional parameters in my routing table.For example I would like the users to browse a product catalog like this:,2,3 etc


View 1 Replies

Handle Optional Parameters In URL Routing?

Jun 2, 2010

I've already implemented URL routing in my app but there are cases where I may or may not get a paramter. In particular, I'm trying to come up with a good way to handle multi-language support. For example, if my regular URL is /SomeCategory/Friendly-Topic-URL, I want to have an optional language selector at the end but I'd like to be optional. So, if I get /SomeCategory/Friendly-Topic-URL/es, that should bring up the topic in Spanish but if get nothing, that should bring up English.

View 6 Replies

Mvc Routing With 2 Parameters/unable To Show The Picture

Nov 15, 2010

I want to do a hyper link such as this

<img src="../Thumb/1342526/1" alt="" /><br />
/thumb(controler)/item number/picture number within item number

my route as I thought is could be [Code]....
it does not show the picture so I assume this is not correct?!#@*(#!&@

View 3 Replies

MVC Routing - Multiple (Optional) Search Parameters

Nov 26, 2010

I'm trying to implement a search function on an incident logging page that is working fine. Currently I am only able to search against one criteria at a time, using the following route:

View 2 Replies

C# - How To Point URL From Global File Using URL Routing 3.5 Without Parameters

Nov 26, 2010

How to point url from Global file using URL routing 3.5 without parameters?

For example:


View 1 Replies

Caching - Exclude Routing Parameters In VaryByParam?

Apr 17, 2010

I have a routing setting in my global.asax file:

routes.MapPageRoute("video-browse", "video/{id}/{title}/", "~/routeVideo.aspx");

My routeVideo.aspx page has caching setting:

<%@ OutputCache Duration="10" Location="ServerAndClient" VaryByParam="id" %>

But when I request http://localhost/video/6/example1 and http://localhost/video/6/example2 after this, the page is created again. So I think VaryByParam works for * but I only want compile when id changes. Is there a way to define routing parameters at VaryByParam?

View 3 Replies

Configuration :: WebForms Routing In 4.0 Multiple Parameters?

Oct 18, 2010

Simple enough I have a search feature I am wanting to impliment Routing for.Here is the routing table for it.


Now I want to set the postback URL for a linkbutton to go to the search page with all parameters filled in but the last one or for that matter any one of the parameters to be left blank


You will see in this example I left the very last one blank. Now when I do that the link does not work. If I fill in all attributes it does workso can anyone tell me how to work around this issue?

View 2 Replies

Web Forms :: How To Use Same Number Of Parameters For Two Pages In URL Routing

May 7, 2015

I have some routes defined in global.asax according to which the page is redirected.

void Application_Start(object sender, EventArgs e) {
} void RegisterRoute(RouteCollection routes) {
routes.MapPageRoute("MainCategory", "{state}/{mcat}", "~/MainCategory.aspx");
routes.MapPageRoute("carriers", "{state}/{mcat}/{dcat}", "~/carriers.aspx");
routes.MapPageRoute("carrierdevices", "{state}/{mcat}/{dcat}/{carrier}", "~/carrieritems.aspx");
routes.MapPageRoute("cellphone", "{state}/{mcat}/{dcat}/{carrier}/{device}/{id}", "~/Catalog.aspx");
//New Rout with same parameters
routes.MapPageRoute("iphones", "{state}/{mcat}/{dcat}", "~/iphones.aspx");

i mean to say how to decide the destination page depending on URL Eg:1.routes.MapPageRoute("carriers", "{state}/{mcat}/{dcat}", "~/carriers.aspx"); 2.routes.MapPageRoute("iphones", "{state}/{mcat}/{dcat}", "~/iphones.aspx");

if value in URL second parameter i.e mcat=cellphone then it must redirect to carriers.aspx. and if mcat=iphone then it must redirect to iphones.aspx page.

Problem:currently if in URL there are 3 parameters then it always goes to carriers.aspx as it searches in route table for 3 parameters it redirects to carriers.aspx which need to be conditionally redirected depending on mcat valuehow to do?

View 1 Replies

Copyrights 2005-15, All rights reserved