问题标签 [asp.net-mvc-5]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
asp.net-mvc - 有没有办法可以在 ASP 中调试路由。MVC5?
过去我使用过一些我认为是微软的 Scott Hanselman 的代码。但是现在我正在使用 MVC5,我认为该代码不再有效。
有没有一种方法可以跟踪 MVC5 中采用的路由,以便我知道为什么我会看到如下消息:
asp.net-mvc - 在 MVC 5 中,如何在没有默认操作的情况下为控制器设置路由?
我有以下内容:
但是我不想指定默认操作。有没有办法为我的 MVC5 应用程序做到这一点?
asp.net-mvc - 如何使用 MVC5 从新的 ASP 身份表中获取 UserId 和 UserName?
在我的 MVC4 应用程序中,我有以下模型:
我对此类/表使用了带有实体框架的选择来获取 UserId 和 UserNames 的列表。
现在我明白它与 MVC5 完全不同。
有人可以告诉我如何使用 MVC5 获得相同的信息吗?有没有我可以使用的内置方法?
asp.net-mvc - HTTP 错误 500.19 - 内部服务器错误 - system.webServer/httpErrors 缺少部分声明
我有以下内容:
并且:
当我运行我的应用程序时,我收到一个错误页面:
有人可以帮我解释一下吗。
我认为我不需要自定义错误页面。但是,我阅读的所有内容都告诉我,解决方案是添加自定义错误页面。
asp.net - 我在哪里可以获得 asp.net 身份的 rtm 控制器模板?
我知道它不是开源的(还),但有人知道如何使最新的 rtm 包工作,或者我可以用来试用它的控制器模板吗?
它似乎与 RC 版本相比发生了重大变化。
asp.net - ASP.NET MVC 5 身份和 Azure
我正在尝试Visual Studio 2013 RC
使用MVC 5 spa template
.
我可以让注册/登录/注销过程正常工作,除非有一个小问题困扰着我。如果我尝试使用错误的凭据登录,返回页面的错误字符串是“发生未知错误”。而不是“用户名或密码不正确”。如果GrantResourceOwnerCredentials
inApplicationOAuthProvider.cs
工作正常,它应该是这样。
在 localhost 上,我得到正确的“用户名或密码不正确”。信息。
Azure 的错误日志:
我不确定它怎么可能是格式错误的语法,因为在提交正确的登录凭据时会发送和处理相同的语法。
有没有人对此有足够的了解,可以知道发生了什么,或者至少有一条途径可以接近知识库文章以外的答案?如果还不是很明显,我是新手——这是我在 ASP.NET 中的第一个网站,第一次介绍 OAuth,第一次使用 Azure。
visual-studio-2013 - 在 Mvc5、EF6、VisualStudio 2013 中使用存储库的脚手架控制器
在 vs2012 中,我曾经使用 Steve Sanderson 的 mvcScaffolding包和这个包,我可以用单元测试和控制器用存储库和依赖注入来构建动作方法。我的问题很简单。在vs2013中有没有办法做到这一点?当我在 vs2013 中安装软件包时,出现以下错误:
asp.net-mvc - 将异步与 MVC5 一起使用有什么好处?
有什么区别:
和:
我看到 MVC 代码现在有异步但有什么区别。一个提供比另一个更好的性能吗?调试一个问题比另一个更容易吗?我应该对其他控制器进行更改以使我的应用程序添加 Async 吗?
c# - How do you login/authenticate a user with Asp.Net MVC5 RTM bits using AspNet.Identity?
Apologies and Thanks in advance for this question! I am still new to SO.
I have been working on a web application using MVC5, EF6, and VS 2013.
I spent some time upgrading to the RC bits once released. Thanks to all the great posts out there: eg. Decoupling Microsoft.AspNet.Identity.* and Updating asp.net MVC from 5.0.0-beta2 to 5.0.0-rc1 !
In my infinite wisdom, I decided to move to the RTM bits that @Hao Kung posted about here: How can I get early access to upcoming Asp.Net Identity changes?. I figured I would save the trouble and not be too far behind when we finally receive the RTM build.
This has either been a nightmare, or I am just completely missing something (or both) as I can not figure out basic tasks that had been working with the RC1 stuff.
While it seems like I am logging the user in via the controller (Where is Microsoft.AspNet.Identity.Owin.AuthenticationManager in Asp.Net Identity RTM version?) ... my WindowsIdentity is always empty and not authenticated after I call SignIn. The user and claimsIdentity object are correctly populated.
Here is the action method I am calling (moved properties to local variables for completeness):
(On a side note: I do not need to log in external users at this time.)
Any suggestions? -or- Should I roll back all my changes and just wait until VS 2013 is RTMd?
Update, refactored code to make it closer to @Hao Kung's original reply. However I still do not end up with a valid user identity. I think my AuthenticationManager is not assigned correctly?
AuthenticationManger is now defined as:
SignInAsync is now a separate method:
After "SignOut", the debugger shows:
The "claimsIdentity" is then:
"SignIn" does not change anything:
Still no Authentication, but seems that no errors are thrown.
As answered by @Hao Kung, changed StartUp.Auth.cs from:
To:
c# - ASP MVC 5 (Microsoft.AspNet.Identity) 中的角色管理
在 ASP MVC5 RC 中,我没有让角色系统工作。我的数据库有一个角色存在的所有需求表,但是如果用户在角色中进行校对总是返回 false(没有 SQL 异常或其他东西)!?
我需要在IPrincipal
某个地方激活角色系统吗?
测试代码:
我还尝试构建自定义扩展,例如命名空间中的IIdentity.GetUserId()
扩展方法Microsoft.AspNet.Identity.Owin
。
但是索赔类型的结果RoleClaimType
总是null
:(我真的坚持这一点。
谢谢您的帮助!史蒂芬