Monday, March 21, 2016

Identify Anonymous Users in Asp.net

Identify anonymous users in asp.net

The first thing when we read about identifying anonymous users in asp.net mvc is "Why do we need to identify anonymous users?". Well the same thought had crossed my mind, but then when developing an e-commerce application, we needed anonymous users to add items to the shopping cart without logging in. We also needed these items to be loaded into the shopping cart, the next time they visited.

How do we do this?

Asp.net provides a guid accessed through the Request.AnonymousId property with which the user can be identified.
  1. Enable anonymous Identification

    Anonymous Identification need to be enabled, else Request.AnonymousId will be null.
    <configuration>
        <system.web>
          <anonymousIdentification enabled="true"/>
        </system.web>
      </configuration>
  2. Access the Anonymous Id

    Anonymous Id can be accessed through Request.AnonymousID property.

Hope this helps someone.

Tuesday, August 25, 2015

Resizing virtual box storage

Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Users\user>cd C:\Program Files\Oracle\VirtualBox

C:\Program Files\Oracle\VirtualBox>vboxmanage modifyhd "C:\Users\user\VirtualBox VMs\Design\Design.vdi" --resize 81920
0%...
Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage.exe: error: Resize hard disk operation for this format is not implemented yet!

C:\Program Files\Oracle\VirtualBox>vboxmanage clonehd "C:\Users\user\VirtualBox VMs\Design\Design.vdi" "C:\users\user\virtualbox vms\design\design_cl.vdi" --format vdi
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'vdi'. UUID: e883d1c3-02a1-43da-97c4-522c1b4be8eb

C:\Program Files\Oracle\VirtualBox>vboxmanage modifyhd "C:\Users\user\VirtualBox VMs\Design\Design_cl.vdi" --resize 81920
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

C:\Program Files\Oracle\VirtualBox>

Monday, October 6, 2014

Enabling Migrations in Entity Framework to update the database programatically

Migrations

Implementing migrations in entity framework

  • Open the Package Manager Console (Tools -> Library Package Manager -> Package Manager Console)
  • Select the project where the entity framework DataContext is contained and then in the console type Enable-Migrations
  • use the following code to update the migrations
  • Now a call to the migrate method on the migrator will result in the database being updated automatically to the current version

Thursday, May 9, 2013

The Web server is configured to not list the contents of this directory. IIS 7.5 asp.net mvc

After adding an app in iis, and running it came across the following issue.

HTTP Error 403.14 - Forbidden

The Web server is configured to not list the contents of this directory.


fixed it using this post

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -i
Microsoft (R) ASP.NET RegIIS version 4.0.30319.17929
Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation.  All rights reserved.
Start installing ASP.NET (4.0.30319.17929).
....................
Finished installing ASP.NET (4.0.30319.17929).

C:\Windows\Microsoft.NET\Framework\v4.0.30319>


another issue while logging in

solved with http://www.aspdotnet-suresh.com/2011/05/systemdatasqlclientsqlexception-login.html

Tuesday, July 17, 2012

error from asp.net 3.0 to asp.net 4.0

Error:
The type 'System.Web.Mvc.ModelClientValidationRule' exists in both 'd:\Program Files\Microsoft ASP.NET\ASP.NET Web Pages\v2.0\Assemblies\System.Web.WebPages.dll' and 'd:\Program Files\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll

Resolution:
Issue resolved as per http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253815

Methods (Copied from http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253815 for reference):



  1. In the root Web.config file, add a new <appSettings> entry with the key webPages:Version and the value 1.0.0.0.
  2. <appSettings>
        <add key="webpages:Version" value="1.0.0.0"/>
        <add key="ClientValidationEnabled" value="true"/>
        <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
    </appSettings>
  3. In Solution Explorer, right-click the project name and then select Unload Project. Then right-click the name again and select Edit ProjectName.csproj.
  4. Locate the following assembly references:
    <Reference Include="System.Web.WebPages"/> <Reference Include="System.Web.Helpers" />
    Replace them with the following:
    <Reference Include="System.Web.WebPages, Version=1.0.0.0,
    Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL "/> <Reference Include="System.Web.Helpers, Version=1.0.0.0,
    Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
  5. Save the changes, close the project (.csproj) file you were editing, and then right-click the project and select Reload.