簡體   English   中英

當前上下文中不存在名稱請求

[英]The name Request doesnt exist in current context

我有簡單的登錄頁面表單。 但是,它給我錯誤說 Request 在該上下文中不存在。 我如何解決它?

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>
    }

在 .NET Core 中,您必須使用 Context.Request 路徑中的 Query 對象。 所以它會是:

Context.Request.Query["ReturnUrl"]

看: 如何從 MVC Razor 標記中獲取查詢字符串參數?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM