MVC :: Redirecting To Same Action Without Parameters?

Jul 27, 2009 08:09 PM

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.


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

Jun 30 10 at 15:00

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

MVC :: Parameters Not Mapping To Action

Nov 12, 2010 10:12 AM

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

How To Pass Model To An Action Which Have Other Parameters

Feb 24 at 12:21

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

MVC :: Optional Controller Action Parameters?

Dec 11, 2009 12:23 PM

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

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

Nov 04, 2009 09:01 PM

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

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

Jan 20, 2010 03:44 PM

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

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

Jul 01, 2010 07:52 PM

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

Calling Action Method In MVC With JQuery And Parameters Not Working

Dec 27 10 at 22:37

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

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

Mar 10, 2011 02:28 PM

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

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

Nov 17 10 at 10:49

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

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

Aug 20, 2009 11:02 AM

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

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

Oct 05, 2009 04:03 PM

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

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

Sep 28, 2009 04:23 PM

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

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

Oct 15, 2010 01:46 PM

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


Where my RegisterRoutes method looks like


View 1 Replies View Related

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

Nov 29, 2010 02:21 AM

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

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

Mar 23, 2011 09:36 PM

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

MVC :: Helper And Action And Google Controller, GoogleController, With An Action Adsense?

Aug 27, 2009 09:46 PM

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

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

Apr 29 10 at 7:36

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

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

Jun 12, 2010 04:15 PM

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

MVC :: Controller Invokes GET Action Instead Of POST Action

May 20, 2010 01:45 PM

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

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

Aug 13, 2009 07:08 AM

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

MVC :: Dynamically Adding Action Filter To Action?

Jun 21, 2010 01:09 AM

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

View 3 Replies View Related

MVC :: Determine Which Action Invoked Particular Action?

Nov 12, 2010 02:56 PM

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

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

Feb 16, 2011 04:48 PM


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

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 10 at 13:44

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

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

Dec 04, 2009 01:26 PM

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

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

Dec 10, 2010 10:15 PM

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

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

May 12 10 at 11:32

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

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

Mar 14, 2010 01:33 AM

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

MVC :: How To Call One Action From Another Action

Mar 31, 2010 09:40 PM

I have a view MemberProfile like this

<% using (Html.BeginForm()
{ %>
<p>FirstName :<%=Html.TextBox("FirstName", Model.FirstName) %></p>
<p>Last Name : <%=Html.TextBox("LastName", Model.LastName)%></p>

View 1 Replies View Related

MVC :: How To Redirect From Action To Another Action

Feb 03, 2011 05:19 PM

I have a page with three partial views. On the first ascx, I want some data posted when a user clicks on "submit" button, and send that data to another POST action "search" and search the db with that data, the final output should be the view returned by "search". How do I do this?

View 3 Replies View Related

MVC :: Force Action Method Can Only Be Called From Another Action Method?

Jun 01, 2009 09:56 PM

I got an action method (say public void ShowMeSomething ), and I do not want users to be able to browse to mysite/this/showmesomething. However I want this action method to be callable from another action method.

View 7 Replies View Related

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

Aug 27, 2010 07:45 AM

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

DataSource Controls :: Use Is Null In Query Without Using Parameters For It Or Should Use Parameters For This Field Where Value Is NULL

Jan 21, 2010 05:21 AM

here is my code for selectiong some records from db table

string strSql = "select * from mtblNBD where SentTo=@SentTo and InternalStatus Is NULL order by DeadLine desc";
SqlCommand com = new SqlCommand(strSql, con);
com.Parameters.Add("@SentTo", SqlDbType.NVarChar, 50).Value = (string)Session["uname"];

here I am using parameters for SenTo field but not for NULL so it is ok... or should I use parameters for this field where value is NULL , if yes then how can I use parameter for this

View 8 Replies View Related

C# - How To Read QueryString Parameters From A Url That's Going To Be Re-written And Hide Those Parameters In The New Re-written URL

Jan 3 at 18:59

I have two examples to show you what I want to achieve here. But to point what's different about my question, Is that I'm having a parametrized URLs and I want to implement URL rewriting to my application. But I don't want to convert the parameter in the URL to be placed between slashes..."page.aspx?number=one" to "pages/one/" << NOT!

First example:


Second example:


But I'll still need all the parameters in the original URLs

View 2 Replies View Related

MVC :: Redirecting From MasterPage In .net ?

Jun 18, 2010 11:22 AM

I have a masterpage on which ill check for a condition if condition is true i want to redirect it to a particular view. how can i do this because on masterpage either view() or RedirectToAction() function are available. My condition is


View 4 Replies View Related

Subdomain And Redirecting To It?

Jun 15, 2010 09:53 AM

I want to have a subdoman ( of all, I don't know how to copy my files to this registered subdomain. Second: I want to Redirect my whole website to a new sudomain. for example if a user types: "" it automatically goes to "". is it possible? if yes, What should I change? Maybe in my master page?

View 4 Replies View Related

MVC :: HttpNotFound Not Redirecting In 3 RTM?

Jan 22, 2011 04:54 PM

On a MVC 3 RTM controller action I have the following:


When I write something like /User/Edit/124, which returns a null user, I just get a blank page with the same url.

But if I write something like /User982738972/Edit/1 then I get the expected 404 page that I set in Web.config.

View 10 Replies View Related

Redirecting A Page To An IFrame?

Mar 17th, 2011, 11:44 AM

I have a web application that's really quite simple. I have a MainMenu.aspx that contains a asp:Menu control and an IFrame. This IFrame will contain other aspx pages based on the selection from the menu.

My question is this: When I have selected a menu option and a specific page has loaded into the IFrame and this new page has a "Cancel" button that simply goes back to the MainMenu.aspx page. How would I code that in the VB.Net code-behind file of this page? I'm assuming it would be in the BT_Cancel_Click() event but I'm not sure how to code it!

View 5 Replies View Related

Copyrights 2005-14, All rights reserved