Restoring NuGet Packages for External Dependencies

NuGet is an excellent visual studio extension and answer to dependency management in .NET. It makes super easy to manage third party libraries. If are working on .NET and have not noticed NuGet, you are missing something very useful, read about NuGet here.
If you have been working on Java platform then this is something similar to Maven dependency management 
In early days… developers used to commit third party libraries (.dlls) into source control, those who don’t tend to get part of GAC. So we have seen developers maintaining folders like Lib, External Libraries etc. as part of repositories or branches into source control. This approach is easy but have it’s own limitation such as version management and manual maintenance etc.
Then comes the NuGet Package Manager to resolve dependencies. It’s has benefit of integration with Visual Studio and manages packages over just libraries (dlls). It creates a “packages” folder to download all external libraries and their dependent libraries along with version management.

NuGet Package Manager
With that developers started committing “packages” folder into source control to share external dependencies across team or contributors and that is fine but over time this would make distributed versioning control systems like Git to grow significantly large due binaries.

Restoring Packages Automatically

With NuGet 2.0, now you don’t need to commit “packages” folder and let NuGet download and restore missing packages when you build solution
For NuGet to do this, you need to take few steps.
1) Check “Allow NuGet to download missing packages during build” in Tools -> Options -> Package Manager
2) Enable NuGet Package Restore
That will do the needful, it would create a nuget folder as part of your solution file and will now automatically restores the missing libraries. What happens is that at the time of build, NuGet reads the packages.config file, identify the missing ones and download the missing packages with mentioned version from NuGet gallery.
This way you don’t have to commit your “packages” file into source control and yet easily maintain dependencies.
Have you tried NuGet Package Manager, dear reader?

MVP Summit 2013 Summary and Take Away

Hello folks!
I am at the Seattle Airport (SEATEC) leaving for home via Dubai waiting for boarding to start. So I thought to utilize the time and share my summit experience.
As I mentioned in a blog post earlier, this was my third time attending the MVP Summit and yet it’s always good to attend the summit, interact with product teams at Microsoft and take something out of it.

Complimentary copies from Practices & Patterns teamTypeScript with Mads togerson
Scott Hanselman on Future of ASP.NETSummit attendee party
But I am not going to share about usual happenings occurred at Summit instead I would like to share some technology updates and good tools I came across at MVP Summit. While much of the content at MVP Summit was under NDA (Non-Disclosure Agreement) yet there are many things that I can share with you and are publicly available as of today. I am going to glimpse through them.

1) ASP.NET and Web Tools 2012.2 Released

One of the recent update announced this week from ASP.NET team is the tooling update for web development. This includes bunch of updates such as support of LESS framework (.less extension), enhancements in Web API, SignalR templates, new template for Facebook application and updated reference to libraries. Note that some of the feature I mentioned in my earlier blog post as part of Web Essential extension are now graduated to Visual Studio as part of this update. Check out detail update on ScottGu blog.

2) PerfView

PerfView is a performance-analysis tool that helps isolate CPU- and memory-related performance issues. It’s a very handy tool if you are into to investigating performance bottle necks so things like blocking time, memory allocation, GC collection time etc. can be identified from using this tool.

This tool is developed by CLR team. It doesn’t have very good UI, but I am impressed by its data and benefits. Also please note that with default options, it’s not very heavy and can be used in production environment as well. Summary: If you are facing performance challenges in your .NET server side apps, give it a try.

3) Visual Studio DevLabs Extensions

DevLabs extensions are experiments/trials of potential upcoming features in Visual Studio. But guess what? you can try them today. I can’t explain much about this, you can check it out on Visual Studio Gallery. Please note that this is in addition to Productivity Power Tools available for Visual Studio which I mentioned in an earlier blog post.
View DevLabs Extensions on Visual Studio Gallery

4) TypeScript

TypeScript is typed super-set of JavaScript and it helps you write JavaScript with static type checking and some sort of benefit of static typed language. For example, it let’s you define interfaces, object type, method type rather than everything as ‘var’. If you write a lot of JavaScript, consider evaluating it. However it’s still in preview version.

Tutorial | Playground

That is all for now, the boarding is about to start in next five minutes.

Keep Exploring!

Attending Microsoft MVP Summit 2013

Hi Folks,
Just excited to share that I will be attending Microsoft MVP Summit 2013 next week in Bellevue and Redmond. The summit is a multi-day event and comprises of technical deep dive sessions with product teams along with variety of networking opportunities. 
This would be my third time attending the MVP Summit, previously attended in 2010 and 2011.

Like always, I will get a chance to meet Visual C#, ASP.NET and Visual Studio team, so I would be happy to take your any respective product specific feedback or feature request that you would like me to discuss with product team. You can share details via contact form or twitter.
Besides, you can also give any feature request to product teams via user voice forums. (see Visual Studio and ASP.NET)

ASP.NET MVC 4 Redirects Incorrect Login URL /login.aspx

When working with ASP.NET MVC and WebMatrix.WebData.SimpleMembershipProvider, I faced an issue of ASP.NET redirecting to incorrect login page i.e. “/login.aspx” in case of unauthorized access. As a result, got server error something like below snapshot

Solution: 

The resolution is simple and somewhat intuitive. Somebody needs to tell ASP.NET my LoginUrl. There are two workaround for that which I have tried and worked for me.
  • Add a LoginUrl key in appSettings in web.config
<add key="LoginUrl" value="~/Account/Login"/>
  • OR Set the form loginUrl in   in web.config
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="3000" />
authentication>
Another way around I found on stackoverflow is to set FormAuthenticationSettings but I didn’t give it a shot.
Finally, if you faced issue of redirect to ~/Account/Logon instead of ~/Account/Login in MVC 4 then make sure to check the PreserveLoginUrl is added and set true in your appSettings as mentioned in ASP.NET MVC 4 release notes
Hope it helps.