从MVC 4升级到MVC 5后,我的应用程序(从Visual Studio中启动时)会出现以下错误.值得注意的是,我在同一个项目中托管MVC5和WebAPI2项目,因为可能存在干扰.我还安装了dotnetopenauth nuget包(我已经删除了):
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /login.aspx
Run Code Online (Sandbox Code Playgroud)
我不确定为什么会这样,因为过滤器或控制器上没有设置授权属性.
Global.asax中:
public class MvcApplication : HttpApplication {
protected void Application_Start() {
IDependencyInjectionBuilder dependencyInjectionBuilder = new DependencyInjectorBuilder();
var builder = new ContainerBuilder();
builder.RegisterControllers(typeof(MvcApplication).Assembly); …Run Code Online (Sandbox Code Playgroud) 我在我的主域example.com上设置了一个项目,然后将其移动到子域sub.example.com
现在,当我尝试在OpenId上使用相同的(默认的ASP.NET MVC或我的Discourse论坛)项目并点击Google按钮使用我的Google帐户登录时,会抛出以下错误 -
那是一个错误.
OpenID auth request contains an unregistered domain: http://sub.example.com
我曾尝试使用谷歌搜索该消息,但显然我是前四个人之一.这里有什么想法?
我正在寻找使用ASP.NET MVC NerdDinner教程学习ASP.NET MVC和OpenId.
我想将NerdDinner中的身份验证系统替换为仅OpenId.我已经下载了最新的DotNetOpenAuth库,但我不知道如何将它们放在一起.任何人都可以帮助快速一步一步的教程吗?
这是否像在库中删除一样简单,还是应用程序需要进行重大更改?
我正在尝试使用Google+ API访问经过身份验证的用户的信息.我已从其中一个示例中复制了一些代码,这些代码工作得很好(下图),但是我无法以一种可以在应用程序启动时重用令牌的方式工作.
我尝试捕获"RefreshToken"属性并使用provider.RefreshToken()(除其他外)并始终得到400 Bad Request响应.
有谁知道如何使这项工作,或知道我在哪里可以找到一些样品?在谷歌代码网站似乎并没有涵盖这:-(
class Program
{
private const string Scope = "https://www.googleapis.com/auth/plus.me";
static void Main(string[] args)
{
var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
provider.ClientIdentifier = "BLAH";
provider.ClientSecret = "BLAH";
var auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthentication);
var plus = new PlusService(auth);
plus.Key = "BLAH";
var me = plus.People.Get("me").Fetch();
Console.WriteLine(me.DisplayName);
}
private static IAuthorizationState GetAuthentication(NativeApplicationClient arg)
{
// Get the auth URL:
IAuthorizationState state = new AuthorizationState(new[] { Scope });
state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl); …Run Code Online (Sandbox Code Playgroud) E-Trade最近发布了他们的API,并提供了一些有用但不完整的技术文档.
有没有人在C#中有一个完整的工作示例,说明这是如何工作的?
我已经能够正确地使用OAuth进行身份验证,但是当从我的帐户或市场数据中获取信息时,服务器会失败.
我正在使用ExchangeUserCredentialForToken函数从授权服务器获取令牌.当我的用户存在于我的数据库中时,它工作正常,但是当凭据是incorect时,我想向客户端发回消息.我正在使用以下2行代码来设置错误消息:
context.SetError("Autorization Error", "The username or password is incorrect!");
context.Rejected();
Run Code Online (Sandbox Code Playgroud)
但在客户端,我只得到协议错误(错误400).您能帮我解决一下如何在授权服务器上获取服务器端设置的错误消息?
来自授权服务器的完整应用程序配置:
using Constants;
using Microsoft.Owin;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.Infrastructure;
using Microsoft.Owin.Security.OAuth;
using Owin;
using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Security.Claims;
using System.Security.Principal;
using System.Threading.Tasks;
using AuthorizationServer.Entities;
using AuthorizationServer.Entities.Infrastructure.Abstract;
using AuthorizationServer.Entities.Infrastructure.Concrete;
namespace AuthorizationServer
{
public partial class Startup
{
private IEmployeeRepository Repository;
public void ConfigureAuth(IAppBuilder app)
{
//instanciate the repository
Repository = new EmployeeRepository();
// Enable Application Sign In Cookie
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = …Run Code Online (Sandbox Code Playgroud) 您将如何设计和实现OpenID组件?
(是"OpenId如何工作")
我意识到这个问题有点重复,是的,我已阅读规范和维基百科的文章.
在阅读了上面提到的材料后,我仍然无法全面了解过程中每个步骤的处理方式.也许缺少的是一个关于OpenID实现如何工作的良好工作流程图.
我正在考虑将OpenID合并到我的一个应用程序中以容纳B2B单点登录方案,我可能会使用DotNetOpenID而不是尝试自己实现它,但我仍然希望在获得之前更好地掌握细节开始.
任何人都可以推荐能够很好地解释它的书籍或网站吗?在这个网站上有一个涵盖基础知识的答案也没有什么坏处.
[编辑]
我将标题更改为更具体的实现,因为显然有很多地方可以获得一万英尺的视图.
我刚刚开始使用Windows Azure,并且已经使用Azure模拟器在本地运行了一个小型MVC应用程序.我注册了免费试用版,下载了我的发布配置文件并将其导入VS2012.发布到Azure并获得一些程序集引用错误.我通过将它们设置为复制local = true来解决这个问题,现在我得到:
Not running in a hosted service or the Development Fabric.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Not running in a hosted service or the Development Fabric.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of …Run Code Online (Sandbox Code Playgroud) 当我与Google OpenID提供商进行乒乓球比赛时,我无法获得友好的名字/昵称/用户名(无论你想叫什么).
我得到的东西看起来很糟糕,如下所示:
www.google.com/accounts/o8/id?id=AItOawmtAnQvSXGhRTkAHZWyxi4L4EKa7xoTT1dk
Run Code Online (Sandbox Code Playgroud)
而不是喜欢的东西
JohnDoe
Run Code Online (Sandbox Code Playgroud)
什么是以友好的方式从Google获取用户名称的协议,比如myopenid呢?
**我正在使用DotNetOpenAuth*
我一直在努力为asp.net mvc实现一个良好的开放式id解决方案 - 而且我转向的地方绝对是死路一条.DotNetOpenAuth太大了,因此我无法获得最简单,最基本,绝对切割和干燥的实现工作.
NerdDinner有一个很有前途的实现,但是无法跟踪所有依赖文件和脚本.不幸的是,DotNetOpenAuth网站几乎没有任何信息可以提供帮助.
是否有人知道一种简单的方法来实现这个实际解释和详细说明它如何与某种选择器一起工作?它被谈得如此之多,但我找到的所有东西都很难处理,因为它真的让我整个团队都没有考虑它.
我们希望实现它类似于堆栈溢出已经如何 - 使用选择器,如果需要,将弹出登录页面.我意识到有很多代码需要为此完成,但是所有内容都只是欢呼并称赞dotnetopenauth,并没有真正教导它.甚至示例项目也不会打开或编译.
它看起来像一个很棒的图书馆 - 但它真的不是为了点击我.
编辑:现在我已经指出了适当的起点.如果你修剪掉所有多余的东西并确切知道基础知识的位置,那就不那么令人沮丧了.
dotnetopenauth ×10
asp.net-mvc ×4
c# ×4
openid ×4
.net ×3
azure ×1
bearer-token ×1
discourse ×1
etrade-api ×1
google-api ×1
google-plus ×1
nerddinner ×1