TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Zulqadar Idrishi
NA
471
71k
Pass complex object on Post Redirection without TempData in .Net Core.
Jun 1 2021 5:27 AM
Currently, I'm working with the following approach and It's working fine but I want to remove the use of TempData. What can I do?
//my class
public myClass{
public int id {get;set;}
public string name {get;set;}
public anotherClass another {get;set;}
}
public anotherClass{
public int id2 {get;set;}
public string name2 {get;set;}
}
//my action method
[HttpPost]
public async Task<IActionResult> Search(string searchId)
{
var ob=new myClass();
TempData["myClass"] = JsonConvert.SerializeObject(ob);
return RedirectToAction("DataList");
}
[HttpGet]
public IActionResult DataList()
{
var val = TempData.Peek("myClass");
var res = JsonConvert.DeserializeObject<myClass>(val.ToString());
return View(res);
}
Reply
Answers (
3
)
Default Value in Modal Popup
Pop up time showing wrong