MVC :: Redirecting To Same Action Without Parameters?

Jul 27, 2009

I've got a route like this:


Which is for registering for event ID 123.

I would like, when someone comes in on a URL like this, to immediately redirect them back to a URL like this:


I will store the event ID in session, so I still know what event they are registering for.

Here's what I tried:


But I wind up in an endless loop, it always redirects *with* the ID parameter, which in turn triggers another redirect, but again, the redirect goes to Event.aspx/Register/123... so I'm caught in a loop.

By the way, I'm on IIS 6 and I'm using the .aspx extension on the controller name as the easiest way to get the routes working. It's worked just fine so far--no problems--other than this redirection issue...

How do I get this working? By the way, I tried this.RedirectToAction("Register") but that didn't work either.

View 4 Replies

Similar Messages:

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 :: Parameters Not Mapping To Action

Nov 12, 2010

I have a problem getting a (very simple wep app this is) parameter to map into my action. The controller code action:

My global.asax:


Problem: Calling a url like /Ax/Delete/525782 always returns the 'ParameterNotFound'-view. Its been bugging me for several hours

View 4 Replies

How To Pass Model To An Action Which Have Other Parameters

Feb 24, 2011

My problem with the following is how do I send the ModelStateErrors to the action Employee, when I go through the catch part in DeleteEmployee


With return View("Employee", model); I a still not able to send the ID and Name as parameter.

View 5 Replies

MVC :: Optional Controller Action Parameters?

Dec 11, 2009

I have lots of action methods that have a Paging object parameter. e.g.

ActionResult Search(string query, Paging paging); and have registered a paging model binder. If the pageSize and pageIndex don't exist, paging goes to the default.

I'd like T4MVC to somehow skip this particular parameter if possible in the helper method generation, so I could simply generate a URL using


Currently, it's either all or no parameters.

How can I mark the paging parameter so that's optionally skipped from the T4MVC generation?

View 1 Replies

Web Forms :: Client Side Form In Masterpage Not Redirecting To Value In "action=" Field?

Nov 4, 2009

I am not getting a page redirect when this form is submitted and I am not sure why I am getting this behavior.Here's my form markup:


The hidden input types are used with the google custom search that is wired to this form. This code is in my masterpage. The masterpage also has the server side form that wraps the whole page so I had to render this one as a client side (because I can't hide visibility of the main form..I think)I am supposed to be redirected to searchresults.aspx and google uses JS to pass back search results into a specified div on the searchresults.aspx page. This behavior was working for me before I converted this website to use someone clue me in on what I have done wrong? Every time I submit the form it just posts back to itself instead of redirecting. I tried both method="post" and "get" and nothing :(

View 13 Replies

MVC :: How To Pass Values To Action Methods Without Parameters

Jan 20, 2010

Is there any possibility to pass values of form elements to action methods but using parameters?I have a form with a lot of input fields and the method signature will get pretty long. Besides the form elements depend on each other so if the user makes a special choice only a subset of the form elements should be displayed so there are several combinationof values to be passed.Can I access the posted values in a generic way through a collection in the controller or something similar?

View 3 Replies

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

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

MVC Action Parameters With Binded Prefix Not Compatible With Url.Route In Global.asax?

Nov 17, 2010

I have a details page containing a form field named UserId. On the same page i have another search form with a field also named UserId.

I am using Html.LabelFor(vm > vm.UserId) and Html.TextBoxFor(sm > sm.UserId) on the two different view models, vm being the view model and sm being the search model. (Yes, the UserId property on the two models has identical names - because they are the same domain property.

When i navigate to the page, the populated UserId on the vm is inserted into BOTH form fields named UserId by MVC. Even the sm.UserId are empty.

That is my initial problem. There are a few ways ti avoid that. My solution was to use the Prefix flag for the sm.


My problem is that MVC can't map the Search.UserId (because of the .) to fit the UserId (prefixed with Search) in the action shown above.

So it seems like MVC has a prefix-feature, that are actually nok fully supported through the Route-handler.

Ofcourse i could rename the Search.UserId to Search_UserId, but then the name dosent match the name MVC expects in the recieving action above. (expects Search.UserId) Renaming The UserId property of the search model would fix the issue, but since it is the same value in the domain, this seems like a workaround.

View 1 Replies

MVC :: Nullable DateTime Action Parameters Parsed In US Format Irrespective Of Locale

Aug 20, 2009

Hi There,

I have a fairly large MVC Project I have been working with for some time. Suprisingly I have only just created an action with nullable date time parameters, IE:

public ActionResult MyAction(DateTime? startDate, DateTime? endDate)

Now when I pass a date formatted for the UK these parameters are NOT populated. When the date is formatted for the US they are.If I pass a UK formatted date that is compatible with the US format the parameter is populated but the month/day are switched round.

In the UK and most of Europe dates are listed Day/Month/Year. IE: 20th Aug 2009 is 20/08/2009 NOT 08/20/2009 as it is un the US.


.../MyAction?startDate=01/01/2009 Works and I get first of Jan 2009.

.../MyAction?startDate=13/01/2009 Fails - start date parameter is empty.


Fails - start date parameter is populated but with 1st May 2009, when it should be 5th Jan 2009.

It's pretty easy to guess what is happening here. For some reason the ASP.NET MVC framework is not picking up the locale when attempting to parse the date. Is this a known bug? If so is there a planned fix?

I have got round this for now by hacking the action so the dates are string parameters that I then parse myself...

View 10 Replies

MVC :: How To Pass Page Parameters To Controller Action Event While Posting The Page

Oct 5, 2009

I am pretty new to ASP.Net MVC. I am trying to create an data entry page. I like to enter data in the asp page and click enter button. This should invoke my action event in the cotroller. I am facing an issue of getting the entered values in the action event. The parameter format is fine, as below.


But when I have large number of values , then It is combursom to pass in paramters. it must be collected in sort of collection or name value disctionary, which we can access in the controller action event.

View 7 Replies

MVC :: "Action Methods Cannot Have Unbounded Generic Type Parameters." Mean?

Sep 28, 2009

What does this mean?Action methods cannot have unbounded generic type parameters. An unbounded generic type parameter has an empty parameter list. An unbounded generic type is also known as an open generic type. For information about unbounded generic type parameters, see the section "Unbounded Type Parameters" in Constraints on Type Parameters (C# Programming Guide).It is written here: Controller Class I understand it in a way, that it is possible to use a generic type as an action parameter, as long as it is restricted with "where". Like explained here: Constraints on Type Parameters (C# Programming Guide) There it is written:

Type parameters that have no constraints, such as T in public class SampleClass{}, are called unbounded type parameters.It would follow that if T had constraints, it would be allowed. However in the first source it is written:

An unbounded generic type parameter has an empty parameter list.This sounds like as if it was not allowed to have any generic type in the parameterlist, that is not bound to a concrete type. Is or is it not possible to use generic typed parameters in actions?

View 3 Replies

MVC :: How To Pass The 2 Parameters To The Action "Initialize"

Oct 15, 2010

I want to pass the 2 parameters to the action "Initialize" when my application launch.


Where my RegisterRoutes method looks like


View 1 Replies

MVC :: Why Synchronous Action Wasn't Executed Until Asynchronous Action Completed

Nov 29, 2010

I'm implement Comet in MVC, I used timer to keep Async request in server, Async request will complete when timer elapsed 1 minute and response to client (to avoid 404 error) and then reconnect to Async Controller. I also wanna execute some Synchronous action during Async request was holding, but the problem is: When an Async action was executed and hold by using timer, the Sync Action wasn't called until Async action (comet long-live request) completed. I did test with firefox 3.6 many times, but the result is the same, so strange, Do you know why ? I have a sub some questions : To implement comet, using timer (response after some minutes elapsed) or thread (response after several time sleeping thread) to hold async request, which is better?

View 1 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 :: Helper And Action And Google Controller, GoogleController, With An Action Adsense?

Aug 27, 2009

I need to display a Google AdSense Ad in a few views of my application.

Basically the ad is created by rendering some javascript code that needs 4 parameters:

String client, Int16 height, String slot, Int16 width

I know the following options:

1) Pass the parameters in the View Models in all views that has an Ad and display it using a Html Helper:

2)Have a Google controller, GoogleController, with an action Adsense that would return the view AdSense with the javascript code.Then on each view I could render this action.I could also have GoogleViewModel to pass the parameters values and have something like:


Will I need to create a Route in my Global file to be able to use these parameters as inputs of the action?

3)I could have 1 and 2 together:

On each view I would call the action Google/Adsense This action would have the parameters Slot, Height and Width Then it would pass those values together with the Pub definined inside the action because for a web site the account client would be the same.the AdSense view would use the Google Adsense helper to render the code because this way I could use this helper across different projects.

View 3 Replies

Test That A Controller Action Simply Returns A Link To Another Action?

Apr 29, 2010

Lets say I have a simple controller for ASP.NET MVC I want to test. I want to test that a controller action (Foo, in this case) simply returns a link to another action (Bar, in this case).How would you test TestController.Foo? (either the first or second link)

My implementation has the same link twice. One passes the url throw ViewData[]. This seems more testable to me, as I can check the ViewData collection returned from Foo(). Even this way though, I don't know how to validate the url itself without making dependencies on routing.The controller:

public class TestController : Controller
public ActionResult Foo()[code].....

View 1 Replies

MVC :: Create Action Not Carrying Model Across To Http Action

Jun 12, 2010

My httppost action doesnt seem to have received my model. The code is below;


i put a breakpoint on the line; return RedirectToAction("Error", "Dashboard"); and i found that appQualif carried no values whatsoever from the form i submitted..

View 5 Replies

MVC :: Controller Invokes GET Action Instead Of POST Action

May 20, 2010

I'm trying to add file upload functionality to a page. I've got a form that posts the selected file to a controller with a 'savefile' method. But if I don't add a get version of 'savefile' I'll get a 404 error. Here is the form code which is presented on the Index page:


And here is the controller code:


Intuitively I don't think I should need a GET version of SaveFile but if omit it I get a 404 error when the form posts. Why should I need a GET version of SaveFile when all I want is to post a form and save the file?

View 4 Replies

MVC :: How To Restrict Action So A User Cannot Go Directly To Action

Aug 13, 2009

Working on a wizard at the moment. The last step of the wizard is a controller action giving a confirmatoin message. How can I restrict this action so a user cannot go directly to this action (using HTTP GET)? I want it only to be accessed via a RedirectToAction from the previous action.

View 2 Replies

MVC :: Dynamically Adding Action Filter To Action?

Jun 21, 2010

Does any one know how to dynamically add ActionFilter to an Action?

View 3 Replies

MVC :: Determine Which Action Invoked Particular Action?

Nov 12, 2010

I have a controller with a bunch of actions as such:


I'm looking for a way to find out which action invoked the other: for instance, when redirecting to Action1, I need to know whether it is coming from clicking "next" button at Action0 or clicking "back" button at Action2. This is is to avoid performing Action1 twice (My app is like a wizard, if I click back button at Action2, I don't want to execute Action1 again).

View 1 Replies

SQL Server :: What If Multiple Output Parameters And Input Parameters And Also Want A Select Table

Feb 16, 2011


When I want to get the output values its okay but I also want returning a table as a result data.But Datareader has no it possible if I want a returning query result and multiple output values togather ?I wrote a test above.I can get output values as sqlparameters. But Datareader attached to a Gridview is empty.can you detect whats wrong here and it doesnt return a query result.So stored procedure is not standart or ı am doing something wrong.this doesnt raise any exception.but not returning any data.


View 8 Replies

How To Define A Route That Have 2 Optional Parameters In The Middle Of The URL The Start An End Parameters Are Digits

Jun 7, 2010

I want to define a route that have 2 optional parameters in the middle of the URL the start an end parameters are digits


View 1 Replies

DataSource Controls :: Want To Verify / To Omit Parameters When Calling SP From ..NET With Optional Parameters

Dec 4, 2009

Is it possible to omit parameters when calling SP from ASP.NET with optional parameters? I have a vague feeling, that I always have to supply all parameters, even optional.By supply, I mean I have to define them as parameters.

View 4 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

How To Get The Individual Parameters From The List Of Dynamic Parameters In A Webmethod

May 12, 2010

I am using jquery ajax method on my aspx page,which will invoke the webmethod in the code behind.Currently the webmethod takes a couple of parameters like firstname,lastname,address etc which I am passing from jquery ajax method using


now my requirement has been changed such that,the number and type of parameters that are going to be passed is not fixed for ex.parameter combination can be something like fname,city or fname,city or city,lname or fname,lname,city or something else.So the webmethod should be such that it should accept any number parameters.I thought of using arrays to do so, as described here.

But I do not understand how can I identify which and how many parameters have been passedto the webmethod to insert/update the data to the DB.

View 4 Replies

How To Tell Create Button To Send To An Action Named Create And To Edit To An Action

Mar 14, 2010

I'm a newbie into MVC and I am like only on chapter 7 in ASP.NET MVC Unleashed so be easy with m


how do I tell Create Button to send to an Action named Create and to Edit to an Action named Edit on the same form?I guess it is possible on ASP.NET MVC if it is possible on ASP.NET Webforms

View 6 Replies

Copyrights 2005-15, All rights reserved