InvalidOperationException thrown regarding DotNetOpenAuth.IEmbeddedResourceRetrieval with Razor view

后端 未结 2 1342
小蘑菇
小蘑菇 2021-01-02 18:54

When my Razor view calls @Html.OpenIdSelector(... I get an InvalidOperationException:

The current IHttpHandler is not one of

2条回答
  •  礼貌的吻别
    2021-01-02 19:11

    Just NuGet the DotNetOpenAuth package. It will setup everything you need in your config file:

    alt text

    1. Right click on the References of your web project in the solution explorer
    2. Add Library Package Reference...
    3. Click on the Online tab.
    4. In the search box type dotnetopenauth
    5. Click Install

    Everything will be automatically setup and the correct assemblies will be downloaded from the internet and added as reference.

    Here's how the web.config file looks like after performing this:

    
    
    
      
        

    UPDATE:

    You could implement a custom resource retrieval provider:

    public class CustomResourceProvider : IEmbeddedResourceRetrieval
    {
        public Uri GetWebResourceUrl(Type someTypeInResourceAssembly, string manifestResourceName)
        {
            return new Uri("http://www.google.com");
        }
    }
    

    and then register it in web.config:

    
        
        ...
    
    

    But I would recommend you using the openid-selector library for generating login forms.

提交回复
热议问题