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


Similar Messages:

Passing JQuery Object And WebMethod Return Value To OnSuccess Function

Mar 31, 2010

I am calling a WebMethod from this code:

if($(this).attr("checked")) {
..
MyWebMethod(variable1, variable2, onSuccessFunction);
}

The MyWebMethod returns an integer, and I want to set $(this).attr("id") of the jQuery object above to the returned integer. Basically, I'm trying to do the equivalent of an MVC Ajax.ActionLink...AjaxOptions {UpdateTargetID =...} However, I can't figure out how to get both a reference to $(this) as well as the returned value. For example, if I do:

MyWebMethod(variable1, variable2, onSuccessFunction($(this)));

I can succesfully manipulate the jQuery object, but obviously it doesn't have the return value from the MyWebMethod. Alternatively, the first code block with a method signature of onSuccessFunction(returnValue) has the correct return value from MyWebMethod, but no concept of the jQuery object I'm looking for. Am I going about this all wrong?

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

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

SQL Server :: How To Query Return All Data In Array Object / Collection Object

Sep 14, 2010

how to query return all data in Array Object ,Hash Table ,And DataTable dataRow

View 4 Replies

AJAX :: Passing Return Value From A Web Service To A Label In A Form View?

Mar 17, 2010

I am using JavaScript to call a web service. The JS is correctly receiving and passing the web service information.

At the moment, the web service returns a country name as a string to a JavaScript alert pop up box as follows:

[Code]....

I want to change this so that web service returns the country name to a label inside an insert item template of a form view.

Is there a way to pass in the label variable to the OnComplete function signature and still account for the variable args?, such as:

[Code]....

View 10 Replies

How To Return Object After Insert

Mar 29, 2011

I am doing a sql INSERT and would like to get a copy of object immediately after insert. Does C# have a command to achieve this??

View 1 Replies

C# - Can Return A Object With Data In It

Aug 11, 2010

I am wanting to get the function below from the file pageDAL.cs to return the object page with the values for whatever pageID I pass in. If I do not need to use a DataSet or DataTable that is fine. What is the best way?

public page getPage(int _pageID)
{
DataTable dt = new DataTable;
using (SqlDataAdapter da = new SqlDataAdapter("select PageID,ParentID,CategoryID,Name,PageHTMLContent,NavigationText,TopMenu,SubMenu,DisplayOrder,Active from Page where PageID = " + _PageID, ConnectionStrings.StaceysCakes))........

View 3 Replies

MVC :: Passing Entire Object Rather Than Just ID?

Feb 22, 2010

I am working on a project where I have a form to create a new user. In that form we have a dropdown list that is populated from another table called ElectricCompanies. The Users table and ElectricCompanies tables are related (each User can only have one electric company, but electric companies can have multiple users). I am having trouble getting the Electric Company object to pass into the Users table. The Users table wants it to be passed as a object of the table ElectricCompanies, but right now it only passes the ID.

This is the code from the UserController under the Edit that I used to populate the ElectricCompany dropdown list:

Dim eleccomp = (From p
In _DB.ElectricCompanySet Select p)
ViewData("ElecComp") = New SelectList(eleccomp,
"ID", "Name")

Is there a way to pass an entire object rather than just the ID?

View 2 Replies

MVC :: Passing Object Through Pages?

Apr 7, 2010

My problem is to save or pass a table object and use it in other page/controller.

I want to pass the object through pages to save just in the last STEP.

My controller:

[Code]....

I need to save the "d" object to use(save to database) just in other page/controller.

View 8 Replies

Return Serializable Object From FileStream?

Dec 30, 2010

I'm a little green when it comes to streaming and serialization...but what i wanna do is make the Upload method on the server return a serializable object to the client (it is void right now). I have a public class ServiceResult that i decorate with [Serializable], and a public class FileTransferService that implements IFileTransferService

[ServiceContract()]
public interface IFileTransferService
{
[OperationContract(IsOneWay = false)]
string Upload(FileTransferRequest request);
}
The implementation does its thing, and then at the end i create and serialize the object and try to return the string
return ServiceResultSerializer.SerializeAnObject(result);
On the client side i call this service using this class
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName = "IFileTransferService")]
public interface IFileTransferService
{
// CODEGEN: Generating message contract since the wrapper name (FileTransferRequest) of message FileTransferRequest does not match the default value (Upload)
[System.ServiceModel.OperationContractAttribute(IsOneWay = false, Action = "http://tempuri.org/IFileTransferService/Upload")]
string Upload(FileTransferRequest request);
}

I'm basically taking this project found on this blog: [URL] And trying to make it return a value that the client caller can use I get an error right now that says: The operation 'Upload' could not be loaded because it has a parameter or return type of type System.ServiceModel.Channels.Message or a type that has MessageContractAttribute and other parameters of different types. When using System.ServiceModel.Channels.Message or types with MessageContractAttribute, the method must not use any other types of parameters. Which i have no idea what it means :P I think cuz im trying to change the Service paramaters.

View 1 Replies

C# - Create And Return A DTO For An Object Which Has 10 Attributes?

Dec 2, 2010

1) I want to know what is the recommended way to create & return a DTO for an object which has 10 attributes and I only want to return 2 with my DTO object.

2) Should DTO's have their own namespace ? If yes, how do we organize them ? Each DTO inside a single class file or all DTO's inside a single class ?

View 2 Replies

C# - ObjectDataSource Return Object From Cache?

Jan 13, 2011

Is there any way to return object from Session when Select is called on ObjectDataSource? Specifically, I have Products object and saved in Session. Now on another page I have ObjectDataSource which will call same bussiness object method to get Products object. Here I want to hook up any event like Selecting and I would like to return Products object from Session to Select method of ObjectDataSource.

View 1 Replies

Passing Variables Through Non HTML Object

Mar 11, 2010

I have a search page which generates a GridView of results based on the search terms entered by the user. One of the columns in GridView is called a DOI (Document Object Itentifier). This DOI is used to find academic papers through [URL] when a user enters a DOI string. What I would like to do is redirect the user to the relevant webpage when they have selected the DOI in the GridView, however, the url for this page is always different. In the page, I have formatted the form tag like so: [URL] and in my GridView, I have formatted the row that I wish to have hyperlinked like so:

<asp:ButtonField DataTextField="DOI" HeaderText="DOI" CommandName="d"/>

Then, in my C# codebehind, I have the following event which aims to redirect the user to the required page, based on the tag they have selected:

switch (e.CommandName)
{
case "d":
searchResult.Attributes.Add("onchange", "window.open [URL]
break;
}

I don't think this code above makes any difference though as the form tag is already specifying the redirected url, nor do I think this task can be done with a html <table> object, as it only accepts static data, rather than a result set generated from a database, which is what I'm doing. I have also looked at the following post as a guide to this type of problem but, taking account of what it said didn't allow me to solve this problem completely. GridView with DDL and selected value

View 1 Replies

Passing Custom User Object To WCF?

Mar 23, 2011

I've implemented a custom ASP.net membership provider to deal with forms authentication. The custom provider uses a custom User object for authentication and authorization. I was wondering If I can pass this object to each WCF call without adding it to the parameters list?

View 2 Replies

C# - JQuery Ajax WebMethod Return Object

Jan 14, 2011

I have a web Method in my C# that is called via Jquery ajax method. The web method should return an object back to the Jquery which will be used to populate. I have tried returning a JsonResult object, the actual object and nothing seems to work! I'm not using MVC (Unfortunately). Is there a way that I can return an object from my web method which can be used by my AJAX method? here is the link for my JQuery AJAX method [URL]

View 1 Replies

MVC: Return Different Views Depending On Object Type?

Jan 3, 2011

my controller, I'm generically deserializing Xml. The object being deserialized to could end up being any number of different types. This, of course, won't be known at compile time. I've created a number of partial views, each of which are strongly typed to a different object that is a possible outcome of the Xml deserializaton.My problem is that I'm struggling with a good way to return the right view. I could always switch on some property in the object, or use a Key/ViewName Dictionary mapping to get the right view name, but I was hoping for something a little more generic than that.Does anyone know of a way that I could implicitly say, "return the view that is typed off of the object I have."?

View 1 Replies

Return A Json Object In Webforms Programming?

Jun 2, 2010

In ASP.Net MVC action methods can return json objects simply by returning something like so:

JSon([whatever])

How do I return a JSon representation of say List<String> with webforms either through a service or through a method in the code behind of an aspx page? This seems incredibly confusing compared to ASP.Net MVC.

View 3 Replies

C# - Return Linq Query Into Single Object?

Mar 16, 2011

I have this code in my controller:

public ActionResult Details(int id)
{
using (var db = new MatchGamingEntities())

[code]...

View 3 Replies

AJAX :: Passing DataSet Object As ResponseText?

Nov 24, 2010

Working with asynchronous postback. onclick of "OK" button i m fetching data from DB and it is in dataset without page-refresh.

DataSet ds = new DataSet();
ds = SearchResult.GetDataTable("dbo.spGetEmployeeDetails", thisConnection, searchItem);

1. How can i pass this dataset object to javascript as responseText?
2. In javascript i have to create table(create rows depending on number of nodes in dataset) and display responseText in aspx.

View 1 Replies

Passing Business Object Structure To UserControl?

Feb 17, 2010

How do it do this. I have this at the moment

[Code]....

[Code]....

This takes a large INT and returns 4 strings from the BO structure HotelFacilities

If I set the private from string to AccommodationBO.HotelFacilities it is fine

If I set the public from string to AccommodationBO.HotelFacilities it moans because the Set section of the private property is wrong. But the set would be an INt.

All I actually want to do, is populate the BO Structure and passit to the user control using a property in the user control code behind. Is this possible ??

Dim jim As New GetAccommodationPricesBLL

View 1 Replies

Passing A List Of Object From A View To The Controller In Mvc?

Mar 26, 2010

ss a list of objects as a paramter in an actionlinkAt the moment when I try to do this the list is always empty by the time it reaches the controller!

<%= Url.Action("ActionName", new { list = Model.ListOfObjects}) %>
public ActionResult ActionName(List<Object> list)
{
//Do stuff
}

View 3 Replies

Using .net Mvc 2 And WCF - Passing Generic Object To The Service Call?

Mar 11, 2011

[DataContract]
public class UserCertification
{
...
}
[DataContract]
public class UserPhone
{
...
}
[code]...

View 2 Replies

Passing Object To Server With JQuery.Ajax()?

Feb 16, 2010

I am trying to implement the same code that was mentioned in this questionCurrently I have the following code:

var pagePath = window.location.pathname;
var paramList = '';
if (paramArray.length > 0) {

[code]...

View 1 Replies

Web Forms :: How To Use Database Return Many Field And Insert In A Object

Sep 28, 2010

how to use database return many field and insert in a object(like any Collection ,Array,Hashtable etc)

[code]....

View 2 Replies







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