Tracking Forums, Newsgroups, Maling Lists
Home Submit Tracker Forums
  Advanced Search
  HOME    TRACKER    ASP.NET


Advertisements:










MVC :: Redirecting To Same Action Without Parameters?


I've got a route like this:

Event.aspx/Register/123

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:

Event.aspx/Register

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

Here's what I tried:

[Code]....

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 (Posted: Jul 27, 2009 08:09 PM)

Sponsored Links:

Related Forum Messages For ASP.NET category:
How To Pass Parameters To An Action Using Html.Action() In MVC?
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?

Posted: Jun 30 10 at 15:00

View 1 Replies!   View Related
MVC :: Parameters Not Mapping To Action
I have a problem getting a (very simple wep app this is) parameter to map into my action. The controller code action:

[Code]....
My global.asax:

[Code]....

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

Posted: Nov 12, 2010 10:12 AM

View 4 Replies!   View Related
How To Pass Model To An Action Which Have Other Parameters
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

[Code].....

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

Posted: Feb 24 at 12:21

View 5 Replies!   View Related
MVC :: Optional Controller Action Parameters?
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

Url.Action(MVC.Home.Search("donuts")).

Currently, it's either all or no parameters.

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

Posted: Dec 11, 2009 12:23 PM

View 1 Replies!   View Related
Web Forms :: Client Side Form In Masterpage Not Redirecting To Value In "action=" Field?
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:

[Code]....

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 ASP.net.Can 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 :(

Posted: Nov 04, 2009 09:01 PM

View 13 Replies!   View Related
MVC :: How To Pass Values To Action Methods Without Parameters
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?

Posted: Jan 20, 2010 03:44 PM

View 3 Replies!   View Related
MVC :: Routing Is Correct, But Parameters Don't Reach The Action Method.
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.

Posted: Jul 01, 2010 07:52 PM

View 8 Replies!   View Related
Calling Action Method In MVC With JQuery And Parameters Not Working
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();
[code]...

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)
//etc...

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?

Posted: Dec 27 10 at 22:37

View 2 Replies!   View Related
MVC :: Making An Html Button Call An Action Method With Parameters?
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.


Posted: Mar 10, 2011 02:28 PM

View 9 Replies!   View Related
MVC Action Parameters With Binded Prefix Not Compatible With Url.Route In Global.asax?
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.

[code]...

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.

Posted: Nov 17 10 at 10:49

View 1 Replies!   View Related
MVC :: Nullable DateTime Action Parameters Parsed In US Format Irrespective Of Locale
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.

So:

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

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

.../MyAction?startDate=05/01/2009

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...

Posted: Aug 20, 2009 11:02 AM

View 10 Replies!   View Related
MVC :: How To Pass Page Parameters To Controller Action Event While Posting The Page
I am prettynew to ASP.Net MVC. I am trying to create andata 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 anissue of getting the entered values in the action event. The parameter format is fine, as below.

[Code]....

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.

Posted: Oct 05, 2009 04:03 PM

View 7 Replies!   View Related
MVC :: "Action Methods Cannot Have Unbounded Generic Type Parameters." Mean?
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?

Posted: Sep 28, 2009 04:23 PM

View 3 Replies!   View Related
MVC :: How To Pass The 2 Parameters To The Action "Initialize"
I want to pass the 2 parameters to the action "Initialize" when my application launch.

[Code]....

Where my RegisterRoutes method looks like

[Code]....

Posted: Oct 15, 2010 01:46 PM

View 1 Replies!   View Related
MVC :: Why Synchronous Action Wasn't Executed Until Asynchronous Action Completed
I'm implement Comet in Asp.net 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?

Posted: Nov 29, 2010 02:21 AM

View 1 Replies!   View Related
MVC :: Redirect Action Not Working In Jqgrid Action Results Method
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..

[Code]....

Posted: Mar 23, 2011 09:36 PM

View 9 Replies!   View Related
MVC :: Helper And Action And Google Controller, GoogleController, With An Action Adsense?
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:

[Code]....
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:

[Code]....

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.

Posted: Aug 27, 2009 09:46 PM

View 3 Replies!   View Related
Test That A Controller Action Simply Returns A Link To Another Action?
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].....

Posted: Apr 29 10 at 7:36

View 1 Replies!   View Related
MVC :: Create Action Not Carrying Model Across To Http Action
My httppost action doesnt seem to have received my model. The code is below;

[Code]....

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..

Posted: Jun 12, 2010 04:15 PM

View 5 Replies!   View Related
MVC :: Controller Invokes GET Action Instead Of POST Action
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 codewhich is presented on the Index page:

[Code]....

And here is the controller code:

[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?

Posted: May 20, 2010 01:45 PM

View 4 Replies!   View Related
MVC :: How To Restrict Action So A User Cannot Go Directly To Action
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.

Posted: Aug 13, 2009 07:08 AM

View 2 Replies!   View Related
MVC :: Dynamically Adding Action Filter To Action?
Does any one know how todynamically addActionFilter to anAction?

Posted: Jun 21, 2010 01:09 AM

View 3 Replies!   View Related
MVC :: Determine Which Action Invoked Particular Action?
I have a controller with a bunch of actions as such:

[Code]....

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

Posted: Nov 12, 2010 02:56 PM

View 1 Replies!   View Related
SQL Server :: What If Multiple Output Parameters And Input Parameters And Also Want A Select Table
[Code]....

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 rows.is 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.

[code]....

Posted: Feb 16, 2011 04:48 PM

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
I want to define a route that have 2 optional parameters in the middle of the URL the start an end parameters are digits

[Code].....

Posted: Jun 7 10 at 13:44

View 1 Replies!   View Related
DataSource Controls :: Want To Verify / To Omit Parameters When Calling SP From ..NET With Optional Parameters
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.

Posted: Dec 04, 2009 01:26 PM

View 4 Replies!   View Related
MVC :: MVC3 RC2 Bug Binding From Request Parameters To Method Parameters?
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

[code]....

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

Update:
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?

Posted: Dec 10, 2010 10:15 PM

View 10 Replies!   View Related
How To Get The Individual Parameters From The List Of Dynamic Parameters In A Webmethod
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

data:JSON.stringify({fname:firstname,lname:lastname,city:city})

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.

Posted: May 12 10 at 11:32

View 4 Replies!   View Related
How To Tell Create Button To Send To An Action Named Create And To Edit To An Action
I'm a newbie into MVC and I am like only on chapter 7 in ASP.NET MVC Unleashed so be easy with m

[Code]....

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

Posted: Mar 14, 2010 01:33 AM

View 6 Replies!   View Related
MVC :: How To Call One Action From Another Action
I have a view MemberProfile like this

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

Posted: Mar 31, 2010 09:40 PM

View 1 Replies!   View Related
MVC :: How To Redirect From Action To Another Action
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?

Posted: Feb 03, 2011 05:19 PM

View 3 Replies!   View Related
MVC :: Force Action Method Can Only Be Called From Another Action Method?
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.

Posted: Jun 01, 2009 09:56 PM

View 7 Replies!   View Related
MVC :: Action Method Returning An ActionResult Used In A Action Method?
I have the Index action method calling a method that itself is an action method.

Example :

[Code]....

What to do in this case ?

Posted: Aug 27, 2010 07:45 AM

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

Posted: Jan 21, 2010 05:21 AM

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
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:

http://localhost:1820/Pages/Default.aspx?page=2&start=5
To
http://localhost:1820/Pages/page2

Second example:

http://localhost:1820/Items/Details.aspx?item=3
To
http://localhost:1820/Items/ItemName

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

Posted: Jan 3 at 18:59

View 2 Replies!   View Related
MVC :: Redirecting From MasterPage In .net ?
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

[Code]....

Posted: Jun 18, 2010 11:22 AM

View 4 Replies!   View Related
Subdomain And Redirecting To It?
I want to have a subdoman (sub.site.net).irst 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: "www.site.net" it automatically goes to "sub.site.net". is it possible? if yes, What should I change? Maybe in my master page?

Posted: Jun 15, 2010 09:53 AM

View 4 Replies!   View Related
MVC :: HttpNotFound Not Redirecting In 3 RTM?
On a MVC 3 RTM controller action I have the following:

[Code]....

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.

Posted: Jan 22, 2011 04:54 PM

View 10 Replies!   View Related
Redirecting A Page To An IFrame?
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!

Posted: Mar 17th, 2011, 11:44 AM

View 5 Replies!   View Related
Copyright 2005-08 www.BigResource.com, All rights reserved