【发布时间】:2019-03-21 07:56:05
【问题描述】:
我正在将项目从 Net 4.6.2 迁移到 Net Core 2。
MVC Net Core 2 中 Request 的替代品是什么?如何替换下面的这一行?
string rawId = Request["ProductID"];
在 Net Core 2 中,我收到了
错误:
Cannot apply indexing with [] to an expression of type 'HttpRequest' HPE.Kruta.Web.Core
https://docs.microsoft.com/en-us/dotnet/api/system.web.httprequest?view=netframework-4.7.2
代码示例:
protected void Page_Load(object sender, EventArgs e)
{
string rawId = Request["ProductID"];
int productId;
if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productId))
{
using (ShoppingCartActions usersShoppingCart = new ShoppingCar
【问题讨论】:
-
你试过'string page = HttpContext.Request.Query["page"]'吗?
标签: c# asp.net-core