ASP.NET MVC saves data after authorization

I have processing the processing of a form message, but I want to make sure that they are authenticated before the action. The problem is that mail data is lost because it is redirected to the login page and then back.

[AcceptVerbs(HttpVerbs.Post)] [Authorize] public ActionResult AskQuestion(string question) { .... } 

Any ideas?

Greetings

+4
source share
3 answers

You need to serialize the values โ€‹โ€‹of the form and RedirectUrl into a hidden field.

After authentication, deserialize the data in a hidden field and redirect based on the value of RedirectUrl.

For this you need a special authorization class.

+2
source

POST is usually used to add, update or delete data. By the time the user does this, if authentication is required, you should already be authenticated. Therefore, I suggest you change the flow of your application for authentication before POST.

+4
source

You can also use a session to save information ...

-2
source

All Articles