MVC2 And MVC Futures Causing RedirectToAction?

Apr 12, 2010

I've been trying to get the strongly typed version of RedirectToAction from the MVC Futures project to work, but I've been getting no where. Below are the steps I've followed, and the errors I've encountered.

I created a new MVC2 app and changed the About action on the HomeController to redirect to the Index page.

Return RedirectToAction("Index")

However, I wanted to use the strongly typed extensions, so I downloaded the MVC Futures from CodePlex and added a reference to Microsoft.Web.Mvc to my project.

I addded the following "import" statement to the top of HomeContoller.vb

Imports Microsoft.Web.Mvc

I commented out the above RedirectToAction and added the following line:

Return RedirectToAction(Of HomeController)(Function(c) c.Index())

So far, so good. However, I noticed if I uncomment out the first (non Generic) RedirectToAction, it was now causing the following compile error:

Error 1 Overload resolution failed because no accessible 'RedirectToAction' can be called with these arguments:
Extension method 'Public Function RedirectToAction(Of TController)(action As System.Linq.Expressions.Expression(Of System.Action(Of TController))) As System.Web.Mvc.RedirectToRouteResult' defined in 'Microsoft.Web.Mvc.ControllerExtensions': Data type(s) of the type parameter(s) cannot be >inferred from these arguments. Specifying the data type(s) explicitly might correct this error.
Extension method 'Public Function RedirectToAction(action As System.Linq.Expressions.Expression(Of System.Action(Of HomeController))) As System.Web.Mvc.RedirectToRouteResult' defined in 'Microsoft.Web.Mvc.ControllerExtensions': Value of type 'String' cannot be converted to 'System.Linq.Expressions.Expression(Of System.Action(Of mvc2test1.HomeController))'.

Even though intelli-sense was showing 8 overloads (the original 6 non-generic overloads, plus the 2 new generic overloads from the Futures assembly), it seems when trying to complie the code, the compiler would only 'find' the 2 non-gneneric extension methods from the Futures assessmbly.

I thought this might be an issue that I was using conflicting versions of the MVC2 assembly, and the futures assembly, so I added MvcDiaganotics.aspx from the Futures download to my project and everytyhing looked correct:

ASP.NET MVC Assembly Information (System.Web.Mvc.dll)

Assembly version: ASP.NET MVC 2 RTM (2.0.50217.0)
Full name: System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Code base: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Web.Mvc/2.0.0.0__31bf3856ad364e35/System.Web.Mvc.dll
Deployment: GAC-deployed

ASP.NET MVC Futures Assembly Information (Microsoft.Web.Mvc.dll)

Assembly version: ASP.NET MVC 2 RTM Futures (2.0.50217.0)
Full name: Microsoft.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null
Code base: file:///xxxx/bin/Microsoft.Web.Mvc.DLL
Deployment: bin-deployed

This is driving me crazy! Becuase I thought this might be some VB issue, I created a new MVC2 project using C# and tried the same as above.

I added the following "using" statement to the top of HomeController.cs

using Microsoft.Web.Mvc;

This time, in the About action method, I could only manage to call the non-generic RedirectToAction by typing the full commmand as follows:

return Microsoft.Web.Mvc.ControllerExtensions.RedirectToAction<HomeController>(this, c => c.Index());

Even though I had a "using" statement at the top of the class, if I tried to call the non-generic RedirectToAction as follows:

return RedirectToAction<HomeController>(c => c.Index());

I would get the following compile error:

Error 1 The non-generic method 'System.Web.Mvc.Controller.RedirectToAction(string)' cannot be used with type arguments

What gives? It's not like I'm trying to do anything out of the ordinary.It's a simple vanilla MVC2 project with only a reference to the Futures assembly.

I'm hoping that I've missed out something obvious, but I've been scratching my head for too long, so I figured I'd seek some assisstance.

If anyone's managed to get this simple scenario working (in VB and/or C#)

View 1 Replies


Similar Messages:

MVC2 Futures Conflicting With Existing System.Web.Mvc?

Feb 9, 2011

I downloaded MVC2 Futures and referenced it to my current MVC2 Project. However, if I want to call an HtmlHelper from MVC2 Futures I need to <%@ Import Namespace="Microsoft.Web.Mvc" %>

So I decided to add it on my Web.Config:

[code]....

but, this caused me errors. Could this assemblies co-exist? If yes, How?

View 1 Replies

MVC :: Ajax Call Causing RedirectToAction/ValidationSummary To Fail?

Jul 26, 2010

I think ive narrowed down my problem, I have a form but the "submit" buttons are being handled by Javascript - since i need to build arrays manually outside of the model for processing

[Code]....

I'm calling the Controller Action "Update" and passing it to string Arrays, when its finished - i want it to redirect to another action - it doesnt.

[Code]....

I just really wanna construct those arrays, and pass them to a controller...i think the ajax is waiting on a result and ignoring the redirect.

View 1 Replies

Looking For View Codding New Futures?

Nov 4, 2010

what are the new futures came in asp.net mvc2.. I am looking for View Codding new futures? Controller coding and Seurity?

View 2 Replies

MVC :: Thoughts On Html.Serialize In The MVC Futures

Feb 3, 2011

I'm learning ASP.NET MVC 2 I want to create a wizard-type application. I was reading you can accomplish this with the help of Html.Serialize method in ASP.NET MVC Futures assembly (To help preserve state as you step through views).

I haven't seen that this is even part of MVC 3.0 as well. how certain this feature will be included for sure in the future? I'm a little wary of relying on it being there.

View 2 Replies

MVC :: 2.0 Futures REST - Cross Domain - JSONP

May 5, 2010

I´m using mvc futures 2 with WebApiEnabled for XML and JSON support. But due to cross domain issues with jQuery $.ajax I´m lookin in to JSONP. Is there a simple way to extend futures rest function for JSONP or should I do something else.

View 1 Replies

RedirectToAction Usage In Asp.net Mvc

Dec 6, 2010

i want to make some questions about asp.net MVC,actually,i am not familiar with web developing.

But,i am assigned for web part.we are using like this.first,we create get set
properties for person data

public class Person
{
public int personID {get;set;}
public string personName {get;set;}
public string nric {get;set;}
}

and then after login,we put data in that class and we use RedirectToAction method like this,

return RedirectToAction("profile","person",new { personID = Person.personID});

it's working normally,but,parameter are shown at URL,how i hide them and also can i hide action name?

View 2 Replies

MVC :: Using ModelState With RedirectToAction?

May 18, 2010

I have created a custom validation attribute for a class. The validation is actually against one property of the class, but since it needs to be compared to another property of the class at runtime, I had to pull in everything from the input form, perform the validation and output the errors. This being the case, I manually added a ModelError to ModelState if the ModelStats.IsValid returned false. I have another thread that goes into this, as I still haven't been able to make the client-side validation work for the custom validation (built-in validation runs client-side without a problem).

Here's the issue: I want to use the Post/Redirect/Get pattern to avoid issues where users refresh their page and cause another post of the form data. If I complete my Controller action and return a View after assigning an error with ModelState.AddModelError, I get the user feedback with the red input field and error message shown. However, just returning a View like this makes you vulnerable to the repeated posts issue. I want to use RedirectToAction to perform a get and avoid this problem, but when I do that I no longer have the ModelState error feedback on my rendered View. Here're the calls I'm making:

[Code]....

I'd like to be able to redirect to a get action and retain the ModelState.

View 2 Replies

MVC :: Passing Int Value From RedirectToAction Method?

Nov 15, 2010

I want to pass a int value using RedirectToAction() method .

Here i have a Action method Index() which takes 1 parameter id in most of the cases this id cannot be null.

When i submit the form using Action method Edit(), i want to come again on Index page,so i am using method RedirectToAction("Index")

but here with Action Name i want to pass the id also. How can i do it?

View 3 Replies

Is There A Strongly Typed RedirectToAction In MVC 2

Oct 2, 2010

I wish to do something like this:

return RedirectToAction<SomeController>(c => Index(someparameter));

How to do this ?

View 2 Replies

Use Custom Route With RedirectToAction (asp.net Mvc)

Mar 8, 2011

I use the RedirectToAction with parameters in my action method

return RedirectToAction("ListThreads", "View", new { category = "1", subcategory = "49"});
After redirect the url comes out like this
http://domain/Forum/View/ListThreads?category=1&subcategory=49
I want it to be generated like
http://domain/Forum/View/ListThreads/1/49

How to do it?

Note : I already have a route in global.asax that is used by all the pages/links.

context.MapRoute(
"Forum_subcategory",
"Forum/{controller}/{action}/{category}/{subcategory}",
new { controller = "View", action = "ListThreads", category = "", subcategory = "" }
);

View 1 Replies

MVC :: RedirectToAction And Instance Of Class?7

Jan 27, 2010

I've a class that hold all the necessary properties. I want to pass the instance of that class in RedirectToAction. Right now, I can pass the instance but the action to which it redirect, doesn't receive that same instance. The target action has new instance of class.

eg.
AbcFilter a = new AbcFilter();
a.ABCname="abc";
RedirectToAction("AbcAction",a);
Public ActionResult AbcAction(AbcFilter a)
{// this method receives the "a" as new instance, but not the same that I pass in RedirectToAction
}

View 3 Replies

MVC :: RedirectToAction Crashing When A Controller Is Specified?

May 18, 2010

I've been using MVC since the previews of 1.0 and I think I know what I'm doing, but for the life of me I can not figure out why sometimes when I use RedirectToAction it crashes saying there is no route available. Consider this in MVC 2.0:

I'm registering on my site and I first hit the SiteController, which does its magic then I am to be redirected to my new dashboard, controlled by the... DashboardController. I never make it there. I specify the action and the controller in the redirect call, but it still crashes and burns. The only thing I can possible think of is because the DashboardController is its own area, but that still doesn't help me because by my understanding it should still work regardless.

View 1 Replies

MVC :: Unit Tests For Action Which Uses RedirectToAction?

Oct 13, 2010

I have Action method in a controller which uses RedirectToAction(actionName, routeValues[])I want to write the unit test for action method to check the following - 1. action name2. ViewData after executing the RedirectToAction.

View 1 Replies

MVC :: Nested RedirectToAction After JQuery Post?

Jun 6, 2010

i built an MVC application, in one of my views, i'm activating an ActionResult using JQuery.$post in this ActionResult i'm using RdirectToAction to another ActionResult, this ActionResult is really reached and executed, but when i'm trying to use another RdirectToAction from here, its not happened.

View 6 Replies

MVC :: Controller Not Called From Actionlink Or RedirectToAction

Mar 4, 2011

I am new to MVC2 and have hit a wall. When I use an action link to jump back to a previous page that I have already been on, my controller is not called but the page is rendered correctly. Is this some sort of caching that I am not aware of? This also happens with a RedirectToAction call from another Controller. rfm is the Model...

return RedirectToAction("Search", rfm);

Here is the actionlink...

<%: Html.ActionLink("Search", "Search", "Reference")%>

View 3 Replies

MVC :: Return RedirectToAction() Passing Object?

Apr 9, 2010

I have the following ActionResult() method:

[Code]....

The method is called once the <form> is submitted. If the validation is good, it moves on to create a new user Once the new user is created, I want to redirect the user to a "ThankYou" page passing along the newly created user (object). The TempData["User"] trick seems to work like a charm! Then inside my ThankYou ActionResult() I do the following:

[Code]....

The problem I have is once the user has been redirected to the "ThankYou" page. If he decides to refresh (F5) his browser, the value in the TempData is lost.

What are my possibilities to overcome this issue?

Instead of passing an entire object to my "ThankYou" page, I initially thought of passing the ID of the newly created user and re-query my database to get the object.

The only problem is that the ID will be seen in the QueryString allowing the user to simply change the ID value and try to find other users...

Is my only other alternative to simply place the user object inside a Session? Is that my only other option?

View 6 Replies

Passing A Controller As A Parameter - Can't Get To RedirectToAction Method

Jun 15, 2010

My method looks like:

public static RedirectToResult(Controller controller, ...)
{
}

when I do:

controller.

I don't see RedirectToAction, how come?

I get RedirectToAction from within the controller's action, but not when I pass the controller as a parameter to another classes method.

View 3 Replies

MVC :: RedirectToAction() Go To View That Was Being Viewed Instead Of Home Page?

Oct 7, 2010

I am using some Html.ActionLinks to change the value of a Session variable. Right now I am RedirectToAction("Index","Home"). This puts the user back at the home page every time they change that value. I would like to return the user to the view they were one when they clicked that link instead of redirecting them back to the home page. How can I do that?

View 5 Replies

MVC :: RedirectToAction Failing To Match Default Route In MVC3

Jan 27, 2011

I have a Search Controller with an action method as follows:

public ActionResult Location(LocationSearchInputModel input)
{
// Get Results and pass cacheId in TempData
return RedirectToAction("results");
}
public ActionResult Results()
{
// Get cacheId from TempData and build Model
return View(model);
}

The call to RedirectToAction fails with the following error message:

Message: No route in the route table matches the supplied values.

My default Route is set up as follows:

routes.MapRoute(null, "{controller}.mvc/{action}/{id}/", new { controller = "Home", action = "Index", id = UrlParameter.Optional });

As the id Parameter in the default Route is optional shouldn't RedirectToAction("results") execute the SearchController's Results action?

It worked in MVC2 :/

View 5 Replies

Pass A JQuery NotifyBar Requirement To The Next View In A RedirectToAction?

Jul 14, 2010

I'm using the jQuery NotifyBar quite nicely in an Index view to display business rule errors when a user e.g. clicks a delete link for an item than cannot be deleted. However, if the user adds a new item, they are redirected to the Create view. If the new item is successfully created, the Create action redirects back to the Index view.

My quandary is that I need (have been told) to show a success notification in the above scenario. Previously, to request a notification while remaining on the same view, I was using return JavaScript() for an action result, but when I use return RedirectAction() for the action result, I'm left with nowhere to put the return JavaScript().

The way I see this is that I need to: a) include information in the return RedirectAction() that tells the 'destination' view to show the notification, or b) invoke the notification in the 'source' view, instead of the return RedirectAction(), and tell it that when it closes/is closed, to perform the redirect to the 'destination' view.

View 1 Replies

MVC :: RedirectToAction Params And Breakpoints / Value Of 'projectID_DDL' Is Null When The Redirect Occurs?

Jul 12, 2010

I have an ActionResult method that loads a user-selected project. When the user makes a selection from a select html element, the id is passed in and loads the project. This works fine. The user can also submit the form, which saves certain information and then calls a RedirectToAction that passes the project id back into the load method. This is where the problem occurs. Here's the relevant code:

[Code]....

The problem is that the value of 'projectID_DDL' is null when the redirect occurs. I'm aware that during a form post that variable is automatically mapped to the name of the html element, so my first question is if that precludes referring to the parameter name as anything else, even in code. In regular methods, it doesn't matter what you call the variable, provided it's the correct type for the parameter it corresponds to, but ActionResult methods might differ. My second question is about break points. In order to test that the value of 'projectID_DDL' is what I passed in, I set a break point. It was never hit. I even tried adding a line before the return View statement, thinking perhaps that the return View statement threw the exception, and so its breakpoint wasn't being hit. This didn't work, either.

View 23 Replies

MasterPageFile Causing Error?

Aug 12, 2010

I'm trying to use a master page in my website. I created a page and then created the master. I then added the tag MasterPageFile="~/master". I'm guessing that I need to do something to my main page, because I've now started getting the error:

The page contains markup that is not valid when attached to a master page

My main page is as follows:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MasterPageFile="~/my.master" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>

I tried deleting the tag thinking that this might be the issue. Can anyone point me in the right direction?

View 2 Replies

Sql - Why Causing A Runtime Error

Jul 15, 2010

I am trying to connect to a database on my local server. The database is called "dbtest." Of course, I have left off my actual password and replaced it with "password."

This is the typical code I see on every tutorial, but it doesn't work at all. Please help.

<%
Dim con, rs
con = Server.CreateObject("ADODB.Connection") 'I think it is something to do with this line
con.Open "Provider=sqloledb;SERVER=localhost;DATABASE=dbtest;UID=administrator; PWD=password;"
rs = Server.CreateObject("ADODB.Recordset")
%>

View 2 Replies

C# - What Could Be Causing Different Behaviour Remotely On .net Site

Jan 25, 2011

I have a site that i have developed in asp.net. On debugging the site now hosted using iis7 i noticed a bug, i cannot reproduce this when i run it locally in vs, meaning i can't see the error. The bug occurs on the check box changed event of a devexpress check box. It connects to the database using devart.postgres sql component and linq. However, this is the same connection as anywhere else in the project. The same code works elsewhere in the project. The error i get is:

the requested name is valid, but no data of the requested type was found.

part of my code is in an if statement that checks if a textbox is blank if so it does not run the code within the if statement, interestingly enough if the text box is blank the code runs, so it must be in the if statement? i commented out all of the code and tried again and it still would not run. B

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved