Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6089151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:04:03+00:00 2026-05-23T12:04:03+00:00

I run an Azure web role in Full IIS mode. Requests are authorized with

  • 0

I run an Azure web role in Full IIS mode. Requests are authorized with custom basic authentication.

I have MyAssembly.CustomIdentity class that inherits from System.Security.Principal.GenericIdentity. When HttpApplication.AuthenticateRequest handler (OnEnter() code from the link above) is invoked it performs checks, then creates an instance of MyIdentity.CustomIdentity and assigns it to HttpContext.Current.User. Then an actual ASP.NET request handler obtains that object and can use it to find what user it is for.

Now everything more or less works fine in default configuration when IIS is running under NETWORK SERVICE account. During role startup I restart IIS application pool under a local user (to grant it extra privileges). Now even the following code

public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        bool isAvailable = Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.IsAvailable;
    }
}

will throw various exceptions. First it says it can’t serialize my CustomIdentity class (which I fix by adding Serializable attribute), then it says it can’t load MyAssembly assembly (which I fix by handling AppDomain.AssemblyResolve event).

What I don’t get is why serialization kicks in? Why running the application pool under s local user and invoking that trivial code suddenly trigger serialization?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:04:04+00:00Added an answer on May 23, 2026 at 12:04 pm

    Be cautious with this answer, as I am not absolutely sure it is the good one.

    First, I assume you haven’t set up something like sql session management, and the only thing you changed is the user under which IIS is running.

    You observe two phenomenon:

    1. Serialization of an object which shouldn’t be serialized
    2. Loading of your assembly by an AppDomain which hasn’t already loaded it.

    As your appdomain has already loaded the assembly, it seems safe to assume that the exception is thrown by another AppDomain. If it is thrown by another Appdomain, it’s probably because this AppDomain is attempting to deserialize your custom object. (It has been serialized before the other exception demonstrates that.)

    OK. Now even if IIS is running under a local user, Role environnement isn’t. This service is installed with the Azure OS, you can’t choose the user it runs under (you could probably in fact, but I wouldn’t)

    What I think is that in order to get informations from RoleEnvironnement, the Azure runtime is able to use two code paths:

    1. One if the IIS service and Runtime are running under the same user, which doesn’t require appdomain switching.
    2. another if the IIS service and runtime doesn’t share the user they are running under. In this case, the runtime requires it, as the two user doesn’t have the same rights.

    To conclude, I certainly don’t know why the Azure runtime would like to move your user between different AppDomain, but it is probably doing exactly that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF Data service hosted in Azure as a Azure Web Role.
I have an Azure web role that accesses an external WCF based SOAP web
I have a web service hosted on azure as a web role. In this
I have a relatively low bandwidth Azure Web Role application and also several processes
Is it possible to have one web role hosted on Windows Azure which respond
I have an azure project in visual studio. It has a web role which
I run a Web Role on Windows Azure to receive AAC audio files (uploaded
I have a JSON web service that I want to run on the same
I am working on an Azure demo to run Powershell in a worker role.
My Azure Web Role needs to be able to delete temporary local files stored

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.