在partialview MVC中获取会话变量错误

编程入门 行业动态 更新时间:2024-10-23 13:38:43
本文介绍了在partialview MVC中获取会话变量错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有人请帮忙:我将此声明添加到我的partialview登录页面

Someone please help out: I added this statement to my partialview login page

@HttpContext.Current.Session["userID"] = User.Identity.GetUserId().ToString();

并收到以下错误:

编译错误

描述:在编译服务此请求所需的资源期间发生错误.请查看以下特定错误详细信息并适当修改您的源代码.

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

编译器错误消息:CS1525:无效的表达式术语="

Compiler Error Message: CS1525: Invalid expression term '='

源错误:

第 66 行:#line default第 67 行:#line hidden第 68 行:EndContext("~/Views/Shared/_LoginPartial.cshtml", 73, 37, false);第 69 行:第 70 行:

Line 66: #line default Line 67: #line hidden Line 68: EndContext("~/Views/Shared/_LoginPartial.cshtml", 73, 37, false); Line 69: Line 70:

推荐答案

我只是直接使用 User.Identity.GetUserId 而不是 session 变量.

I just use User.Identity.GetUserId directly instead of session variable.

谢谢大家.

不过,如果有人能解释该错误的含义,我将不胜感激.

Still, I appreciate it if someone can explain what that error means though.

更多推荐

在partialview MVC中获取会话变量错误

本文发布于:2023-10-31 16:29:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546637.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   错误   partialview   MVC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!