5

In the implementation for my service I have:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

In my .config file I have:

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

and:

  <system.web.extensions>
    <scripting>
      <webServices>
        <authenticationService enabled="true" requireSSL = "false"/>
      </webServices>
    </scripting>
  </system.web.extensions>

and:

<authentication mode="Forms" />

In the "Login" method for my service, I have:

FormsAuthentication.SetAuthCookie(request.UserName, false);

However, when I check:

HttpContext.Current.User.Identity.Name

It is an empty string. What am I missing?

3 Answers 3

1

Forms authentication is used when you want the user to fill out a login form.

For a service it would be better to use a different authentication mechanism.

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

Comments

1

Try using ServiceContext.User.Identity instead.

Comments

0

I assume you are checking the Identity.Name on a subsequent request?

Do you have an element in your web.config?

Also are you making sure to capture the cookie from the Login response and resending it on the subsequent requests?

Comments

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.