1

I am trying to set up a simple website which uses DotNetOpenAuth as its membership provider. Everything was going great until I ran into the following exception.

[SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
    System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
    System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) +31
    System.Security.CodeAccessPermission.Demand() +46
    System.Net.Configuration.DefaultProxySection.PostDeserialize() +103

The code is below. Unfortunately I cannot reproduce the problem on my local machine. This is being hosted on GoDaddy shared hosting. The line which causes the exception is openid.CreateRequest(id):

public virtual ActionResult Authenticate(OpenIdAuthenticationViewModel model, string returnUrl)
{
    OpenIdRelyingParty openid = new OpenIdRelyingParty();
    var response = openid.GetResponse();

    if (response == null)
    {
        Identifier id;
        if (Identifier.TryParse(model.OpenIdUrl, out id))
        {
            try
            {
                var openIdRequest = openid.CreateRequest(id);
                var result = openIdRequest.RedirectingResponse.AsActionResult();
                return result;
            }
            catch (ProtocolException pe)
            {
                ViewData["OpenIdMessage"] = pe.Message;
                return View(model);
            }
        }
        else
        {
            ViewData["OpenIdMessage"] = "Invalid Identifier";
            return View(model);
        }
    }

    // code that handles response
}

I've tried changing the requirePermission attribute of

<section name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection" requirePermission="false" allowLocation="true" />

but that only caused a different root for the exception stack trace. There is very little information to be found on this exact exception on the web.

1 Answer 1

1

This looks like it's because you've got a web.config with the following snippet:

<system.net>
    <defaultProxy enabled="true" />
</system.net>

Try removing the <defaultProxy> tag, which shouldn't be necessary on GoDaddy anyway.

Sign up to request clarification or add additional context in comments.

2 Comments

I got the package from nuget, and from the package description it is version 3.4.6.10357. I can give you any other information you would like.
Great. I misread the error message in your question anyway. I've updated my answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.