Friday, May 03, 2013

IIS Url Rewrite and HTTP POST data

If you play around with IIS Url Rewriting rules and try to do redirects on an HTTP POST you loose your POST data.

To make sure you get the post data you have to set the `redirectType` to `Temporary` within your rules. So the action configuration looks like this

<action redirecttype="Temporary" type="Redirect" url="http://{HTTP_HOST}{REQUEST_URI}"> </action>

You may think what scenario warrant a POST request redirect. We faced one such scenario while doing SSO with a federated Identity Provider (IP)  such as Google, Azure AD. In federated authentication scenario once the user is authenticated by the IP, it redirects back to your site with claim tokens in a POST request over secure channel (https). In our case we wanted to redirect to user back http after receiving the request. But any redirects were causing loss of token. By doing a 307 (Temporary) redirect we were able to preserve the post data.

Thursday, May 02, 2013

Remote login on Azure Roles

In case you do not follow this guy :), there has been one significant change to Azure which would make developers life much easier while debugging and testing an azure deployment.

You can now enable remote login into azure deployment without requiring you to enable it during the package creation. This means even if the deployment happened with Remote login not enable, you can still enable remote login from azure management portal directly. More details are available here 

So no more forgetting remote login option. Just do a deployment and if required enable remote login from azure management portal.

Friday, January 18, 2013

Logging .Net Exception Details with Complete Stack

I learned today that in .Net doing a ex.ToString() would log the complete exception details including any inner exception details. The important thing here is that it would do this recursively so if there is an InnerException it would call ToString() on it, which in turn can call ToString() on the next level hence forming a recursive chain.

So we can do away with such format string

System.Diagnostics.Trace.TraceError("The error was {0}. Stack Trace {1}. InnerException Details {2}",ex.Message, ex.StackTrace,ex.InnerException.Message);
 

Thursday, January 10, 2013

Google Driven Development GDD

In this era of TDD, BDD, DDD and all other  *DDs, we have a breed of developers doing Google Driven Development (GDD). Sounds interesting, indeed it is :).

Here is how to identify a GDD guy
  • This person does not believe in writing anything on his own, copy/paste from blogs, articles, source code is a way of life. And since I have not written it I don't care how it works as long as I see something working. His best friends are Ctrl-C, Ctrl-V and Google.
  • Cannot write 5 lines of code or code for 5 minutes without doing a Google search.
  • His productivity is directly related to performance of corporate network, and how fast Google searches. If the network is down, it's better to go for a coffee.
  • Search hours on Google for "Object reference not set to an instance of an object" and then believes that the whole world is facing the same issue. Who cares what the context of problem is.
  • To solve the error
    • He then tries each and every solution that Google GOD provides.
    • If by fluke he is able to fix or camouflage the issue, he considers himself something special, but in his heart he knows he has no clue what happened. Thanks Google for saving his day and continues his pursuit to become a better GDDer.
    • If not, then it's time for the Lead, the next GOD in Line. The Lead should be able to fix this issue, What else are Leads there for :)
  • Reading documentation is so very lame ! Documentation is for sissies,  real developers do Google.
  • Religiously believes that all results returned by Google are correct. Google has employed a huge workforce just to make sure results are correct. 

Feel free to comment and tell me more such traits of a GDDer and i would add to my post :)

I may have exaggerated a bit, but what to do, I am seeing such people one too often.


Sunday, January 06, 2013

Azure and Package Deployment for Specific Roles





When a single Azure Subscription Service has multiple roles (Web and Worker) in it, updates to the role cannot be selective. Time and again I have had scenarios where I wanted to update the one role but did not want to touch the other. But as Azure deployment works, there is a single package and it updates all roles in the subscription. 
While doing an update today I was pleasantly surprise that now while updating the site I do have an option to select which specific role to update. Here is what the dialog looks like now


So now we can update specific roles without touching other ones. Great!!!

Things to keep in mind here would be, once deployment is complete you cannot tell which role was updated and which is still running on a older version. But the deployment name does change. So i think this is a good feature for some quick fixes, else we should stick to simultaneous updates only.

Saturday, December 15, 2012

Angularjs and inplace edit

AngularJS is an awesome framework and Angular Directives make this framework super awesome :)

AngularJS  directives help us extend the existing HTML DSL. You can create new tags, extend functionality using existing tag and create reusable component.
I recently created a Inplace editable control in AngularJS. It basically allows to do in place editing for elements like H1, H2, H3 div etc, basically all read only control. I took the initial idea from this fiddle and added
  • Text selection on edit.
  • Cursor positioning
  • Handle the Enter key press.
Here is my fiddle



Sunday, December 02, 2012

Integrate ASP.Net MVC + WebAPI with Autofac in 5 mins

Recently i configured Autofac with ASP.Net MVC 4 and WebAPI. Here are the steps required to configure Autofac
  1. Install package Autofac.MVC4
  2. Install package Autofac.WebApi
  3. Add a class AutofacBootstrap. Use this class to configure the dependencies within your project.
  4. Open Global.asax file and add a method like
  5.  Call the method from Application_Start
  6. And you are done !!