How to add comments to a class library?   Leave a comment

Go to Properties of the class library and make sure “XML Documentation file” checkbox is checked. Build the library and you can see an XML file in the bin folder.


Posted September 22, 2017 by Vasista Bhargav in Visual Studio

Remove Version Discloser in MVC applications   Leave a comment

  1. To remove X-AspNetMvc-Version, add the below code in Application_Start of Global.asx

MvcHandler.DisableMvcResponseHeader = true;

2. To remove X-AspNet-Version and Server header, add the below method in Global.asax


3. To remove X-Powered-By header, add the below code under System.webServer in web.config file

<remove name=”X-Powered-By” />

Posted September 22, 2017 by Vasista Bhargav in ASP.NET MVC, c#

How to enable CORS in MVC?   Leave a comment

  1. Need to add Access-Control-Allow-Origin header value for each request that requires CORS support :

HttpContext.Response.AppendHeader(“Access-Control-Allow-Origin”, “*”);

2. Add this in the web.config file :




<clear />

<add name=”Access-Control-Allow-Origin” value=”*” />




We can follow either of the way.

Posted May 11, 2017 by Vasista Bhargav in ASP.NET MVC, c#

Issue : Azure cloud deployment fails : Certificate with thumbprint was not found   Leave a comment

What worked for me was:

  1. Goto powershell and type mmc
  2. Add certificates snap-in by going to File > Add/Remove Snap-in > Choose Certificates from the list > Choose My user Account
  3. Right click on Certificates – Current User and select Find Certificates
  4. On the dialog box, set Contains to ‘azure’ and Look in Field to ‘Issued To’
  5. Press Find Now. You should be able to see a list of certificates.
  6. Check for the thumbprint by double-clicking the certificate > Details tab > scroll down to Thumbprint
  7. Once you found your certificate, close the dialog, Right click and select Export
  8. Select to export the private key. Follow the steps until you have a *pfx file for upload to Azure
  9. Goto your service and select the Certificates tab
  10. Click Upload, select the exported *pfx file, and supply the password you’ve set during export
  11. Goto Dashbord and update the Cloud package
  12. List item

Credits : StackOverflow

Posted April 6, 2017 by Vasista Bhargav in Azure, c#

Issue : Error while publishing web role in VS 2013: There was an error reflecting type ‘Microsoft.Cct.AzureDiagnostics.ObjectModel.PublicConfig’   Leave a comment

  1. In your Azure project, edit any diagnostics.wadcfgx files in a text editor, and set <IsEnabled>false</IsEnabled> (near the bottom)
  2. Right click project > Publish, untick Send diagnostics data to Application Insights, hit Next

Credits : StackOverflow

Posted April 6, 2017 by Vasista Bhargav in Azure, c#

Check if a property exists in a dynamic variable   Leave a comment

using System.Linq.Expressions;

public bool IsPropertyExists(dynamic dynamicVariable,string propertyToCheck)
IDynamicMetaObjectProvider metaObjectProvider = dynamicVariable as IDynamicMetaObjectProvider;

if (null == metaObjectProvider) throw new InvalidOperationException(
“The supplied object must be a dynamic object ” +
“(i.e. it must implement IDynamicMetaObjectProvider)”

DynamicMetaObject dynamicMetaObject = metaObjectProvider.GetMetaObject(

IEnumerable<string> propertyNames = dynamicMetaObject.GetDynamicMemberNames();
bool exist = propertyNames.Contains(propertyToCheck);
return exist;
catch (RuntimeBinderException)
return false;

Usage :

bool propExists = IsPropertyExists(dynamicVariable, “Prop1”);

Posted February 9, 2017 by Vasista Bhargav in ASP.NET MVC, c#

How to insert a byte array into SQL Server varbinary column   Leave a comment

This can be done using Parameterised Queries as below :

string command = “Insert into [dbo].[Students] (Sname,BinaryColumn) Values (‘raees’,@binaryData)”;

SqlCommand sqlCommand = new SqlCommand(command, con);

sqlCommand.Parameters.AddWithValue(“binaryData”, [binary data]);



Posted January 31, 2017 by Vasista Bhargav in c#, Database