Friday, October 19, 2012

Error message 401.2 After Installing a Web App on One Server But Not The Others


Symptom:

I have a standard ASP.NET application that works fine with any other IIS 7 server, but on a very specific server when I installed my application the I get the following error.

Access is denied.

Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.

Error message 401.2.: Unauthorized: Logon failed due to server configuration.  Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server.  Contact the Web server's administrator for additional assistance.


I have done everything obvious like;
  • Check to make sure that application pool is run by a specific user, in my case Nework Service
  • Made sure that the above user has the full access. In fat, in desperation I have tried to make Everyone Full Control, and still I had above error.
Root Cause:

I did not write II7, so I do not know exactly why in one case it is like this way. Not quite undrestood at this time.

Workaround:

Yes, I was able to work this issue around, and this may as well be the right solution.
  • From the IIS 7 manager, go to the application to directory. You should see on the right panel the familiar ASP.NET and IIS sections with a bunch of icons.
  • Under the ASP.NET section, double click .NET Authorization Rules
  • Under the Actions panel all the way to the right click Add Allow Rule...
  • When the dialog appears select "All users"
Now try accessing the web page again.

Note, I am not responsible for any security related issues specific to your web application. This is a workaround for me, I do not care so much about security since in my situation the page is well deep behind firewalls and no public access.



Friday, October 12, 2012

ASP.NET: 'GridView1' fired event Sorting which wasn't handled. Even with LinqDataSource in Use

 Symptom:

  • I have written an ASP.NET application with a GridView (any bound control) and enabled sorting on the control. 
  • I have manually "swapped" the LinqDataSource by another. In my case I have several that contain different Dynamic LINQ statements in them. Next thing you get the following error and the columns will not sort.

The GridView 'GridView1' fired event Sorting which wasn't handled.

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.Web.HttpException: The GridView 'GridView1' fired event Sorting which wasn't handled.


Root Cause: 

You are likely to have assigned a LinkDataSource to the DataSource properly. This will not work.

Fix:

If your situation is exactly like mine, like below:

       if (false==String.IsNullOrEmpty(like))
        {
            GridView1.DataSource = this.LinqDataSourceDateDesc;
        }
        else
        {
            GridView1.DataSource = this.LinqDataSource2;
        }
        GridView1.DataBind();


Then this will not work.

Fix this to use the ID of the Data Source, and the event for the sort will hook right back up again.

       if (false==String.IsNullOrEmpty(like))
        {
            GridView1.DataSourceID = "LinqDataSourceDateDesc";
        }
        else
        {
            GridView1.DataSourceID = "LinqDataSource2";
        }
        GridView1.DataBind();


Side Note:

Often when I get stuck with a problem like this, I write a simple test program that would demonstrate the situation. In this day and age, many application projects are already scaffoldded so it's just easy to come up with something quickly. In my case the grid was working initially when I built everything from the designer but as soon as I try to go fancy by assigning the data source, it broke. So this way I went back reproducing basically the original flavor, then looked at the source (in this case in the Default.aspx) and that worked, and quickly realized that it is the DataSourceID they use to bind, no other codes to hookup the events were in this simple code. 

I have seen many novice engineers getting stuck for hours or even days on an issue. If they simply wrote a case to demonstrate the issue then they could have spent much less time fixing the issue.

Monday, October 08, 2012

Apple Mountain Lion Upgrade: Why Wait Until Weekend is a Good Idea

Mountain Lion is a highly recommended upgrade and it is less than $20 to get. Besides in order for you computer not to be obsoleted you should upgrade as more and more apps will come out that only works for the later OS versions.

So, of course, you should be wondering why upgrading your Mac to Mountain Lion should be done on weekend.

If you are ready, I would schedule a time of upgrade and I recommend that you do this a few hours before you go to sleep.

This is because Mountain Lion upgrade is a "production interrupting" event, and it will actually not make your computer usable reasonably for up to several hours. In my radiology job, this is very customary, we do not upgrade any computers until all the radiologist are gone home.

After the computer boots up when the upgrade is applied and you log on, there are two things that are very time consuming.
  • Some re-indexing activities like building of Spotlight and such. Many people have reported that Mountain Lion is "slower" but this is because initially it takes a while for this rebuilding activity to complete. So leave it alone and let it finish and it will be faster.
  • As I wrote in another article, Mac Mail files must be migrated from the original location to the new "sandbox" location. This can take hours to complete in some cases.
So my best recommendation is to do this upgrade Friday at 9 PM. Let is do its thing over night (be sure to turn off auto-sleep). And you can reserve Saturday and Sunday to sort out various post-upgrade thing, if necessary to talk to the Apple Genius, back ready for production on Monday.


Mac Mountain Lion: Mail Migration Taking Forever or Never Completes

Symptom:

We upgraded a Mac from Lion to Mountain Lion. After launching the Mail program, it says "Migrating" but it takes quite a while until the progress bar goes to 100% then it hangs.

Workaround (may not be a fix):

I do not have sufficient time to diagnose this completely but the reason for the migration is that it needs to copy all of the files in the Mail storage from one location to another. This is likely for a better security.
  • First, be aware that a lot of people do not manage their email. They simply have thousands and even millions of email messages, attachments and even undumped email trash. So this will take quite a while. I would do this over night to see if it was just taking time. Be sure that you change the computer sleep time to "never."
  • One possibility is that Microsoft Entrouge may be affecting it. I know a good chunk of people do not use Entrouge so in our case, I just dumped the entire Entrouge in the trash.
  •  Next, restart your Mac in the Safe Mode. Note that this can take about 10 - 20 minutes of its own time before it starts. This is because the Mac needs to do a process of file system check before allowing you to use it in the Safe Mode. Do not panic. Just let it do its thing.
  • Be sure to set the computer sleep time to Never. It will still be several hours of processing!
  • Launch the mail, and see if it starts, head for your favorite club, dance all night, come home sleep whatever left of the morning. When you wake up, do not go to the computer, make coffee or tea, take shower, dress and go back to your computer... and voila! I think your computer is showing the usual email list.
  • Note: Please do not post a comment if it does not work. Instead call Apple for support. I do not work for Apple and I myself do not use Mac Mail instead just check my email on the web or I use Nexus 7 Android tablet and iPhone. Perhaps you would want to start using web email just in case this sort of thing happens in the future. If you want to manually clean the email data, they are stored under ~/Library but you would want to search such topic using your favorite search engine provider.