简体   繁体   English

ASP.NET MVC 标识用户 id 到 int

[英]ASP.NET MVC Identity User id to int

I'm using ASP.NET Core with full .NET Framework and Identity and trying to change the user id type to int.我正在使用具有完整 .NET Framework 和 Identity 的 ASP.NET Core,并尝试将用户 ID 类型更改为 int。 I followed these steps ( https://medium.com/@goodealsnow/asp-net-core-identity-3-0-6018fc151b4#.1uxf4m1s8 ) and it generates right tables and columns to the DB.我遵循了这些步骤( https://medium.com/@goodealsnow/asp-net-core-identity-3-0-6018fc151b4#.1uxf4m1s8 ),它为数据库生成了正确的表和列。 I get this error when running the code (locally with Visual Studio 2015) and have no idea what to do:运行代码时出现此错误(在本地使用 Visual Studio 2015)并且不知道该怎么做:

System.Exception: de95f9a1-0d40-4922-a19f-0f300a69955c is not a valid value for Int32. System.Exception: de95f9a1-0d40-4922-a19f-0f300a69955c 不是 Int32 的有效值。 ---> System.FormatException: Input string was not in a correct format. ---> System.FormatException: 输入字符串的格式不正确。

It tries to open the start page but fails before anything is displayed.它尝试打开起始页,但在显示任何内容之前失败。

It seems to me that some part of the code still tries to use wrong data type for the id but I can't pinpoint what.在我看来,代码的某些部分仍然试图为 id 使用错误的数据类型,但我无法确定是什么。 I have my own SQL database running locally and everything was working fine until I tried to change user id to int.我有自己的 SQL 数据库在本地运行,一切正常,直到我尝试将用户 ID 更改为 int。

Perhaps there was Identity data of an old logged user in the cookies.也许 cookie 中有旧登录用户的身份数据。 I had the same problem and my solution was to delete all cookies from the site and refresh the page.我遇到了同样的问题,我的解决方案是从站点中删除所有 cookie 并刷新页面。

I still don't know what was wrong but I just re-cloned the repo to an earlier state and remade the necessary changes as described in the linked article.我仍然不知道出了什么问题,但我只是将 repo 重新克隆到了较早的状态,并按照链接文章中的描述重新进行了必要的更改。 Now it works.现在它起作用了。 Must've made a mistake somewhere.一定是哪里弄错了。 Thanks for the help.谢谢您的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM