The name Request doesnt exist in current context

I have simple form for Login page. However it is giving me error saying Request doesnt exist in that context. How do I fix it?

model Phishing.Models.PersonClass
    

    @using (Html.BeginForm("Login", "Home", new { ReturnUrl = Request.QueryString["ReturnUrl"] }, FormMethod.Post))
    {

        <input type="text" autocomplete="off" placeholder="username" name="UserName" />
        <input type="text" autocomplete="off" placeholder="password" name="Password" />
        <button type="submit">Log in</button>
    }

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

In .NET Core you have to use Query object from Context.Request path. So it would be:

Context.Request.Query["ReturnUrl"]

look at: How to get query string parameter from MVC Razor markup?


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x