Click here to Skip to main content
15,886,093 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ListController
C#
public ActionResult GetPart(string Part) {
    UnsavedPartInfo.PartNumber = Part;
    return RedirectToAction("InsertNewRecord", "Create");
}



CreateController

C#
public ActionResult InsertNewRecord() {
	PartInfo m = new PartInfo();
	m.PartNumber = UnsavedPartInfo.PartNumber;
	m.Plant = UnsavedPartInfo.Plant;
	m.Model = UnsavedPartInfo.Model;
	m.PackagingType = UnsavedPartInfo.PackagingType;
	m.Revision = UnsavedPartInfo.Revision;
	if (UnsavedPartInfo.PDate == "") {
		m.PDate = DateTime.Today.AddYears(2);
	} else {
		m.PDate = Convert.ToDateTime(UnsavedPartInfo.PDate);
	}
	m.ContainerCode = UnsavedPartInfo.ContainerCode;
	m.SkidCode = UnsavedPartInfo.SkidCode;
	m.ContactNo = UnsavedPartInfo.ContactNo;
	m.DunnageCode = UnsavedPartInfo.DunnageCode;
	m.PartPicDesc = UnsavedPartInfo.PartPicDesc;
	m.DunnagePicDesc = UnsavedPartInfo.DunnagePicDesc;
	m.ContainerPicDesc = UnsavedPartInfo.ContainerPicDesc;
	m.Approved = UnsavedPartInfo.Approved;
	m.NoDunnagePerCont = UnsavedPartInfo.NoDunnagePerCont;
	m.NoContPerSkid = UnsavedPartInfo.NoContPerSkid;
	m.NoPartsPerCont = UnsavedPartInfo.NoPartsPerCont;
	m.LoadedPartWeightLbs = UnsavedPartInfo.LoadedPartWeightLbs;
	m.SkidGrossWeightLbs = UnsavedPartInfo.SkidGrossWeightLbs;
	if (UnsavedPartInfo.FinalApproveDate == "") {
		m.FinalApproveDate = DateTime.Today.AddYears(2);
	} else {
		m.FinalApproveDate = Convert.ToDateTime(UnsavedPartInfo.FinalApproveDate);
	}
	m.Comment = UnsavedPartInfo.Comment;
	return View(m);
}


My view has a link to an actionresult where a user chooses a part, and goes to GetPart. The problem I have is getpart is leaving its Part=######### after it gets redirected back to my InsertNewRecord Action. This is bad because when I go to post my action, it errors out! Is there a way to clear that query string out at all? Or redirect to the action without passing it?
http://localhost:56195/List/GetPart?Part=159951159[^]

Edit: Basically, I just want to get back to localhost:56195/Create/InsertNewRecord after setting my static variable. What I am getting instead is a redirection to my desired action, but the url is still looking at localhost:56195/List/GetPart?Part=1599551159.
Posted
Updated 5-Aug-13 10:17am
v3
Comments
TryAndSucceed 5-Aug-13 18:08pm    
Why don't you directly call InsertNewRecord and then check if there's any part? If yes, then insert it, otherwise give user a message to select a part.
Gerenatian 5-Aug-13 21:26pm    
Insert New Record is in an entirely different Controller. Thanks though, because you just gave me the idea of just combining the two controllers into one to fix my issue, ill try that first thing tomorrow. I am using the mobile MVC template, and I think this issue has alot to do with jquery mobile..
Mehdy Moini 13-Sep-13 13:56pm    
Redirect() and RedirectPermanenty(), redirect you to another URL
http://stackoverflow.com/questions/17517318/redirect-vs-redirectpermanent-in-asp-net-mvc
http://stackoverflow.com/questions/17462748/redirectpermanent-is-not-working-in-mvc3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900