Posts

Showing posts from April, 2015

Extract all MVC / WebApi area/controller/actions

I did some search and created my own based on the answers found in SO.

Extract all MVC / WebApi area/controller/actions - Gist

// http://stackoverflow.com/questions/5508050/how-to-get-a-property-value-based-on-the-name // http://forums.asp.net/t/1600843.aspx?How+list+all+of+the+Actions+in+an+MVC+application+for+security+audit+ // http://stackoverflow.com/questions/5801630/mvc-get-all-action-methods // http://stackoverflow.com/questions/21583278/getting-all-controllers-and-actions-names-in-c-sharp // http://stackoverflow.com/questions/15690834/asp-net-mvc4-list-of-all-areas // http://stackoverflow.com/questions/1091853/error-message-unable-to-load-one-or-more-of-the-requested-types-retrieve-the-l /// <summary> /// Extract all MVC/WebApi area/controller/actions /// </summary> publicclassResourceHelper { privateconststring NamespacePrefix = "github"; publicstatic List<ApplicationResource> GetResources() { var resources = new List<ApplicationResource>()…

Bing-Mail Easy Post Api - Version 1.3 - C#

Recently I had a chance to integrate an awesome and innovative postal mailing API (http://www.bingmail.com.au/) in my system. However I ran into some problems because their code samples were in PHP and doing the same from .NET was giving me errors. Finally I found a solution and may be someone out there will benefit from it.

The most frustrating error I had to fix was uploading files as a PUT HTTP method with Digest Authentication.

Complete solution except some easy-to-figure-out methods are posted in this gist. Bing-Mail Easy Post Api - Version 1.3

What i did was modified the DigestAuthFixer from http://stackoverflow.com/a/3117042/959245 to support any HTTP method.

Then used that to create the session, when we create the session using DigestAuthFixer it stores the Digest-Auth headers which i can reuse when uploading the files.
 using (var client =newWebClient()){var uri =newUri(_easypostHosts[2]+UploadUri.FormatWith(sessionId,HttpUtility.UrlEncode(fileName)));// get the auth heade…

Upgrading to ASP.NET Identity 2 - Then Fix Errors

I am working on a MVC5 project but a lot of libraries it has referenced were outdated. Therefore I just opened up "Managed Nuget Pkgs For Solution" and clicked on update all button. It did update all and then I was so happy, i built the project, and ran it.

Lucky Me! I got these errors. Sounds familiar?

The model backing the 'ApplicationDbContext' context has changed since the database was created. This could have happened because the model used by ASP.NET Identity Framework has changed or the model being used in your application has changed. To resolve this issue, you need to update your database. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=301867).  Before you update your database using Code First Migrations, please disable the schema consistency check for ASP.NET Identity by setting throwIfV1Schema = false in the constructor of your ApplicationDbContext in your application.       public ApplicationDbContext() …