28

Jul

2013

How to fix ‘Runtime/Server Error’ redirect issues when adding Azure ACS authentication to an ASP.Net Project

So, I’ve been working on an ASP.Net project for the University over the last few weeks, and part of the remit was to have login functionality present. Being the lazy student I am, I stated the case for using Windows Azure’s ACS service for this and the guy running the project seemed to like what I said, so I went ahead and started to implement it.

Followed a helpful guide by Teemu Tapanila (great guy), and everything went smoothly. Setup the access control namespace, added Identity and Access to VS2012, entered in all the correct details, ran the project locally and hey presto! It worked.

So, basking in the euphoria of my success, I instantly went to publish the project live so had something to ‘show off’ to the project lead. This is where the problems began…

With the site published, I went to test login. The page came up fine, I selected my identity provider, entered my details then upon redirection I was presented with a runtime error.

servererror

This was the first time I’d ever seen a screen like this, with this being one of only a handful of web projects I’ve worked on. So I really had no clue how to go about fixing this. I tried all the usuals, double checked I’d followed the guide correctly, tried it with a completely new, blank project etc, none of this worked. So in desperation I added a comment to Teemu’s guide stating my problem and asking for advice; being the nice guy that he is, Teemu quickly asked for my skype ID so we could get to work fixing the issue. Low and behold, within around 10 minutes it was fixed!

Now when I was googling possible fixes to this error, it seemed as though other people were getting it, so here’s how we fixed it in my case.

Firstly, open the Identity and Access panel from VS:

identnaccess

Add your App ID URI and the Return URL to the correct boxes, enduring they match and MAKE SURE you click ‘Overwrite Existing rules configuration for this application’.

Now, switch to the configuration tab, enter the same URI here in both boxes and then check ‘Enable web farm ready cookies’.

config

Now, click the OK button and let Identity and Access do it’s thing. It should be updating the Web.config file with the URIs and URLs you’ve just added. The problem stems from the project thinking that after authentication it should re-direct you to localhost. After following these steps, the problem should go away.

So you can now publish your site and try the login again and hopefully this time it should work as intended!

Let me know if this helps anyone.

Big thanks to Teemu for helping me with this.

About The Author

Dene