Registering a service using Autofac and getting the list of services via Container in MVC Controller

Using a DI framework (I am using Autofac in my case), you can register the services like below  in AutofacConfig.cs class inside Configure() method as below var builder = new ContainerBuilder(); builder.RegisterType<MyClass>().As<IMyInterface>(); Now you can loop through the list of services in the container .You can either get the entire list of services , or […]

Storing string with Enums in VB.Net

Below is one of the ways to store/retrieve   string data type using Enums . This is particularly useful in situations where  you have to deal with string values repeatedly in your project and don’t want to run into gotcha errors because you mistyped a string . Imagine an  Event logger  where you log multiple error […]

Get Browser name from User agent String

Earlier this week, I was working on a task requiring me to get  the browser  name visitors used to browse the website.A quick Google search gave me  hundreds of results most of which referring to ASP.Net’s request Object .This request object  contains  a property  browser  that returns an object of type HttpBrowserCapabilities.This object contains properties  […]

HOW TO GET THE FOLDER PATH WHERE MY CURRENT .aspx FILE RESIDES IN VB.Net

I came across a situation , where I had multiple folders in my application (Lottery,Single DOnation ,Multiple Donation).Each of these folders contained multiple .aspx files with same name with hierarchy as shown below Donation -Single Donation >>Index.aspx >>details.aspx >>confirm.aspx -Multiple Donation >>Index.aspx >>details.aspx >>confirm.aspx -Lottery >>Index.aspx >>details.aspx >>confirm.aspx The logic was written so that based […]