Wednesday, June 21, 2017

In-Memory OLTP in Azure SQL Database

Hey guys, good news for you all who use Azure SQL Database.

Below are some of the cool features Microsoft added in Azure SQL Database:

  • Earlier including the index created with the primary key, the memory-optimized table can have up to 8 indexes only. Now with the changes incorporated in June 2017 we can create more than eight indexes on memory-optimized tables
  • No more alter table command to change the memory-optimized objects, sp_rename can be used for renaming memory-optimized objects
  • You will no longer see the Error 41839 – “Transaction exceeded the maximum number of commit dependencies and the last statement was aborted. Retry the statement.” Microsoft eliminated the limit on the number of commit dependencies
  • Now we are free to use the CASE expression, the CROSS APPLY operator, and all JSON functions, isn't it interesting!
  • Did you even think of using computed columns in memory-optimized tables, if you think in such direction then please start using computed columns in memory-optimized tables

Thursday, June 15, 2017

How to Encrypt Managed Disks using Azure Storage Service Encryption (SSE)

Microsoft keeps adding more and more security features in Azure and the latest addition to that is the Azure "Storage Service Encryption"

Today we will see how to enable the Azure storage encryption.

Within 3 to 4 clicks we will be able to encrypt the storage account.

Lets login to the Azure account first. Once you login click on the "Storage Accounts" Menu.

New blade will be opened with all the available storage account you have created.

Storage Accounts

Now you select the storage account you want to encrypt, you will find the Encryption option, just click on the "Encryption" option.


Here in the right pane you will be able to Enable or Disable the Encryption. At present this feature is available for Azure Blobs and Files.

But nothing to worry more options are going to come soon.

Also you need to keep it in your mind that once you Enable the encryption only new Data will be encrypted, all the existing files will remain as it is.

Thanks for visiting my blog, please leave your comment below.





Monday, February 22, 2016

How to use Toastr.js in ASP.NET

First let me ask you a question, what is Toastr.js and what is the use of it?

Toastr is a simple JavaScript library which can be used along with jQuery to show a simple and appealing notification in your web application. Good thing about Toasr is, since it is a JavaScript library it won’t create any performance issue and the coding looks very simple.

Lets start with a very simple .net application with one label, textbox and a button. Then on click of the button we will show the Toastr alert.

image

First we need to add the Toastr library like below in your .aspx page.

<script src="http://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript"></script>
   <Link href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.1/css/toastr.css" rel="stylesheet" />
   <script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.1/js/toastr.js" type="text/javascript"></script>

Here you might have noticed that I am referring the path directly from the online URL. In your case you may download the toast.js and toastr.css and also the jQuery and refer it internally.

Now we will write the code to show the alert.

protected void Button1_Click(object sender, EventArgs e)
       {
           Page.ClientScript.RegisterStartupScript(this.GetType(),"toastr_message", "toastr.error('Please Enter Name', 'Error')", true);
       }

On click of the button Toastr message will be shown like below. You can have a condition based on your requirement to show the alert.

Here I didn’t show that because everyone got their on requirement.

image

You have many option to show different color, different title and different icon depends on the message.

Another sample below is for success,

image

Similarly you have toastr.info and toastr.warning to show the alert.

Another useful option you may require is the position where you want to show the alert.

Below are some of the options available in toastr,

toastr.options = {
  "closeButton": false,
  "debug": true,
  "newestOnTop": true,
  "progressBar": false,
  "positionClass": "toast-top-right",
  "preventDuplicates": false,
  "showDuration": "300",
  "hideDuration": "1000",
  "timeOut": "5000",
  "extendedTimeOut": "1000",
  "showEasing": "swing",
  "hideEasing": "linear",
  "showMethod": "fadeIn",
  "hideMethod": "fadeOut"
}
I hope you enjoyed reading this article. Please try this in your project and let me know your client feedback. I am sure they will definitely like this.

Friday, February 19, 2016

The underlying provider failed to open error in C#

 

This is one of the very common error we use to get while using Oracle database. The error “The underlying provider failed to open” is bit confusing if you are not able to view the inner exception.

Once you get the exception, just expand the exception try to read the inner exception. Whihc will be more clear than this.

I just exapanded the exception and the actual error we get is “ORA – 12154: TNS:could not resolve the conect identifier… ” If you read this exception it will be more clear and you might know what needs to be done.

Below is the screen print of the error.

image

I assume you have installed Oracle client in your machine. This error just because you missed the 3 required files

1. tnsnames.ora

2. sqlnet.ora

3. ldap.ora

So in order to resolve the error “ORA – 12154: TNS:could not resolve the conect identifier…” you have to copy three files to the oracle installation location.

Oracle installation folder may vary depends on where you have installed the software and the windows version.

I have given you two possible location normally oracle get installed.

C:\app\client\<Userid>\product\12.1.0\client_1\network\admin

or

C:\Oracle\product\12.1.0\client_1\Network\Admin

If you cannot find Network and Admin folder in Client_1 path you may create those two folders.

Now you try to run the code and see if the issue gets resolved or not.

I hope it helps you to resolve the issue.

Thanks you for visintg my blog.

Sunday, January 10, 2016

Build failed without any error in Visual Studio 2013 update 4

This is one of the very strange error you may find sometimes. Especially when you build a new system or when you install visual studio 2013 first time.

There are many reasons for this error. If you search in Google you may find many solutions here I am going to give you a different solution which worked for me after a thorough investigation.

What happened in my case was, when I open Visual Studio 2013 it shows as running in Administrator mode, but actually it is not. I didn’t right click and run as administrator while opening Visual Studio.

image_thumb2

Now if you build your application which require administrator rights your build may fail. Again not always and not all projects.

So to resolve this issue what you have to do is open Visual Studio in Administrator mode. Just right click on the Visual Studio 2013 from the start menu and click on Run as Administrator. Now you try to build the project which failed without any error. It must work.

image_thumb4

I hope it helps, as I mentioned at the top this is not the only solution to this problem, but this is definitely one of the solution which worked for me. So thought of sharing with you all.

Friday, June 19, 2015

Webinar - Test Driven Application development on June 28th 8:00 PM

We are starting webinar in DotNetSpider. You may find many good technical sessions soon from DotNetSpider.

Fist webinar will be presented by Mr.. Gaurav Arora who is one of the senior member of DotNetSpider.

Gaurav will be presenting “Test driven application development” in his webinar scheduled on 28th June 8:00 PM

Request all my readers to make use of this opportunity. We will be soon coming up with Azure series…wait and watch.

Please joined this session on 28th June 8:00 PM to 9:30 PM.

You may just open the below link to join this session.

https://www.livemeeting.com/cc/mvp/join
Meeting ID: WP8QRC
Entry Code: g)$F3SBxp

Monday, March 16, 2015

How to create One ASP.NET application / What is One ASP.NET?

Did you ever face an interview question “What is One ASP.NET?” Did you ever create One ASP.NET web application? Do you know how to create One ASP.NET web application? All these questions will be answered here.

First lets find the answer for “What is One ASP.NET?”

As the name suggests One ASP.NET, it is a one ASP.NET project for multiple .NET supported technologies. Now you have MVC, WEB API, ASP.NET etc where you can create web application. How about creating one ASP.NET project and integrating all these technologies. Microsoft was reading our developers mind and they came up with ONE ASP.NET concepts in the same way what we all are thinking.

Now you just need to create one web project and then you can decide what technology you wanted to use at any time without any migration from one to another. Which means you can pick the technology at any time no need to decide everything in advance.

In order to create One ASP.NET project you should have Visual Studio 2013 and Update 1 or above.

Now, lets see how to create ONE ASP.NET project.

It is again the standard template as usual you see when you create new project from Visual Studio.

Lets see the step by step process to create the One ASP.NET project.

First thing is, if you don’t have .NET framework 4.5.1 and visual studio 2013 with minimum update 1 then install that.

Once you install the above Open Visual Studio 2013 and go to File—> New—>Project

image

Select Visual C# and then select the .NET framework 4.5 or 4.5.1.and then select the ASP.NET Web Application. As soon as you click on “ASP.NET Web Application” template you may see the description of this template in the right pane as using this you can create ASP.NET web forms, MVC etc, type of applications.

image 

Click OK to create the project and start your application as per your requirement.

I hope now you understood what is One ASP.NET and how to create One ASP.NET project using Visual Studio 2013.

Thanks a lot for reading my article. Keep visiting my blog!

Wednesday, March 11, 2015

Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format. - WCF IIS Hosting error

“Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format” is an error which you get while hosting the WCF service in IIS.

Lets see the complete exception details first,

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.

image

Reason for this error:

You get this error normally when you try to host a WCF service developed in Windows 32 bit machine and you are trying to host this in a 64 bit machine.

Solution to this issue is a simple one, you just need to change the settings in IIS to enable 32 bit application hosting.

Lets see the step step by actions to change this settings.

Open IIS --> Press Start button + R and then type inetmgr.

Expand your server and then click on Application Pools

In the list of application pools select the application pool which is being used by your new WCF service. And then click on the “Advance Settings…”

image

In Advance Settings dialog change the Enable 32-Bit Applications settings from False to True and Click OK.

image

Now you browse your WCF service and see the result. I am sure your error would have disappeared.

Tuesday, March 10, 2015

Can we insert explicit values into IDENTITY column in MS SQL

This is one of my favorite interview question. I hope you also would have faced this question, if not then there is a high possibility that you may face it soon!
Answer to the question Can we insert explicit values into IDENTITY column is MS SQL is YES. You can insert values into the IDENTITY column as you require.

Lets start step by step.

First lets create a table for the demo purpose,
CREATE TABLE DemoIdentity
(
    Id int IDENTITY (1, 1) not null,
    Name varchar(50) not null,
    [Address] varchar (100) not null,
    Phone char (15) not null
)
 
Table is ready, now we will insert some values to the above table.
INSERT INTO [DemoIdentity] ([Name] ,[Address] ,[Phone]) VALUES ('Asheej','Bangalore','9916123456')
INSERT INTO [DemoIdentity] ([Name] ,[Address] ,[Phone]) VALUES ('David','Birmingham','7543789234')
INSERT INTO [DemoIdentity] ([Name] ,[Address] ,[Phone]) VALUES ('Cliff','Columbus','4081234567')

Above is the standard way to insert the values into the table which has IDENTITY column.
image
Now lets try to insert a value with identity column value,

 
INSERT INTO [DemoIdentity] ([ID], [Name] ,[Address] ,[Phone]) VALUES (4,'Johnson','Perth','61478976782')

If you execute above SQL statement you will get below error,
Msg 544, Level 16, State 1, Line 11
Cannot insert explicit value for identity column in table 'DemoIdentity' when IDENTITY_INSERT is set to OFF.

Yes, now we will see the property which MS SQL provides you to insert values in IDENTITY column.
In SQL we have the property named IDENTITY_INSERT. Whenever you wanted to insert values to an IDENTITY column we just need to enable the property IDENTITY_INSERT.
Lets enable this property and insert a value in above table.
Syntax for enabling the IDENTITY_INSERT is,
SET IDENTITY_INSERT [DemoIdentity] OFF

Now we will insert the value by executing the same above statement by specifying the IDENTITY column value and see the result.
 image
One important thing you have to remember is, in order to enable or disable the IDENTITY_INSERT  property you should be part of the sysadmin group.

Make sure you disable the IDENTITY_INSERT ON once you are done with the insert statement as this column is not intended to insert the values explicitly.
Syntax for disabling the IDENTITY_INSERT is,
SET IDENTITY_INSERT [DemoIdentity] ON
 
I hope now you understood the whole concept of the property IDENTITY_INSERT and how you can insert explicit values into an IDENTITY column.

Friday, March 6, 2015

The requested content appears to be script and will not be served by the static file handler – WCF IIS Hosting error

This is one of the most confusing error you get while hosting WCF service in IIS. Solution is simple but the error description completely misleads you to think in all the direction.
Below is the exact error,

HTTP Error 404.17 - Not Found
The requested content appears to be script and will not be served by the static file handler.

image

The reason for the error is when you host a WCF service which is developed in .NET Framework 4.0 or 4.5 then while deploying by default IIS select .NET Framework 2.0.

In order to resolve this issue go to IIS and change the .NET Framework to the version which was used to develop your WCF service.
The exact step would be,

Press Start button  + R  and then type inetmgr.

Expand your server and then click on Application Pools

In the list of application pools select the application pool which is being used by your new WCF service.

Here you would have already noticed the wrong framework associated with your WCF service.

Just double click on the WCF Service name and change the .NET Framework version.

image
Click OK to save the changes. Now you browse your WCF service all your issues with your WCF service hosting error would have resolved.

Monday, March 2, 2015

Where to find log files for the ASP.NET web application hosted in Windows Azure?

If you are a developer then definitely one of the question haunting you once you deploy your web application in Windows Azure is where is the log file? How can I go through the default log files which we have in IIS or in any other web server.

In this article all your such query will be answered. Once you login to your windows Azure account and open the web application configuration section you will find the option to configure all the log files, but there is no options available there to download or to view the log files. You may find all below options under Configure Menu but not the option to view the log files.

image

Lets see the available options to view the log files.

There are two ways you can view the log files related to your web applications deployed in Windows Azure.

1. Kudu Console. If you are hearing this first time then you may read my earlier article “” Once you open KUDU console you just need to go to the Tools menu and then you will find an option “Diagnostic dump” By clicking on this item will download the whole log files dump in your local system. Once you have the dump then nothing more to write about what you have to do.

image

2. Using Visual Studio: This one is interesting as you will be seeing the log files from your Visual Studio itself. In order to view the log files first you need to connect your Visual Studio with your Windows Azure account. If you are not aware of this feature, I have already written an article for you “”.  

Once you connect to your Visual Studio to your Windows Azure account then Expand Azure—>Websites—>Now expand the website name which you wanted to view the log files.

image
As soon as you expand your website which you wanted to view the log files you might have noticed a folder named “Log Files” This is our target today.
 
Lets expand the files and see the subfolders inside Log Files.
 
One thing you have to remember is this folder structure under log files in totally depends on the logging mechanism you have enabled for your application.
 
If you have enabled all the available logging then you may find many folders for each logs.
 
For your information I have expanded few of my already deployed in applications in my Windows Azure account.
image
Try to pen each log files under each folder if you like to explore more about the log files.

I hope you are now clear about the available log files in Windows Azure and how you can download or view this log files for debugging the issues.

Thanks a ton for reading my article and I hope it will help in your application development.

As usual you are always welcome to give feed back to my articles which may help me to improve next time.

Thursday, February 26, 2015

How to Enable Failed-Request Tracing / Not able to find Failed-Request Tracing option in IIS

Sometimes we have to enable Failed request tracing in order to trace the issues in the server. Normally we use Failed Request tracing to know what exactly is happening with the request. Best examples to enable Failed Request tracing is to find out the performance issues, authentication failures, Server 500 error, 404 error etc.

Sometimes when you try to configure the Failed Request Tracing you may not find that option because you may not have installed the IIS components to enable that feature. So first lets see the place where you will find this option.

Lets open IIS first, press Window + R button or Start –>Run and then type inetmgr.
Expand your system name—>Sites—> Click on Default Web Site.

Now look at your right side window “Actions” In Actions pane under Configure section you should get “Failed Request Tracing…. “ option.

Sometimes as I mentioned above you may not see this option. It will be like below screen.

 image
In such cases first we will install the required component.

Go to Control Panel\All Control Panel Items\Programs and Features and then click on Turn Windows features on or off.

Go to Internet Information Service-->World Wide Web Services--> Application Development Features—> Select ASP.NET

Expand Health and Diagnostics—>Select Tracing

Click OK to install this component.

image

Once you install above components open IIS again and go to the Action and under Configure section you can see Failed Request Tracing…

image
To enable Failed Request Tracing Click on the link “Failed Request Tracing…. “ and select the Enable button. You can also change the path in case you wanted to save this log file in a different location than the default location. Also as you can see you will be able to change the Maximum number of trace files as well. This is to avoid your Disk getting full with trace files. Last 50 or 100 file would be sufficient to investigate any issues.
image
I hope now you are clear on how to enable Failed Request tracing and were you can see the Trace log files.

Wednesday, February 18, 2015

App Suspended feature in .NET Framework 4.5.1

Today we will go through one of the new feature added in .NET framework 4.5.1. This feature is currently available only in Windows Server 2012 R2. Microsoft may add this in other operating systems later but currently this is restricted to Windows Server 2012 R2.

App Suspend is a new configuration in IIS in Windows Server 2012 R2. We will see what is the advantage we are going to get if use this configuration and also will see where we have to change this configuration.

First thing first! What is the advantage of using app suspend?

If you enable this great feature your application start up will be much faster and in single webserver server you can host multiple application without impacting the performance.
image
Now, lets see how enable this feature.

In order to enable first we will open IIS from your Windows Server 2012 R2. Open IIS—> Select Application Pools—> Right Click on Application Pools and then select the “Advance Settings…”.

In advanced Settings window you will not see this feature anywhere! isn’t it? Yes you cannot see this feature directly. This feature is part of the “Idle Time-out” settings.
 
You would have noticed a special configuration here that is nothing but the “Idle Time-Out Action” this is currently available only Windows Server 2012 R2. This is the configuration we have to change. By default it will be selected as “Terminate”.
 
Just click on this dropdown to see that the new option “Suspend”. and select the same and click on OK to return.
image
That’s all you have to do, you are done!!!

If you like to test this feature then change the default time to 2 min or something and access the application. Also change the setting back to terminate and see your application start up time difference.
I hope you understood the advantage of this App Suspend feature and you will try this in your application.

Monday, February 16, 2015

Visual Studio In-built Support for Windows Azure

As you are aware Visual Studio has evolved a lot and every new release Microsoft adds many features. Since Windows azure is the hot cake in the market, of course Microsoft added many inbuilt features in Visual Studio 2013. Today we are going to explore few important features which will help you to debug your application.
 
Lets go through one by one, lets connect to Windows Azure website form Visual Studio.

Now you can directly connect to your Azure website from Visual Studio. IN order to connect to the windows azure, first you need to sign in to your Azure account. If you are already connected then you can directly open the server explorer form View Menu.

image

Once you open Server Explorer, you can find an option named “Azure”. You may expand the Azure to find the available options under that. This links nothing but what you see once you login to your Azure account.
 
You can compare the feature list below. Except Visual Studio online everything can be found there. Visual Studio online is a different configuration so that is available under Team explorer in Visual Studio.

 image image
Now what we are going to explore is the features available under Websites.
 
Lets expand the Websites, you will notice that all the websites which is already hosted in your Azure account will listed there.
image
We will concentrate on one website now and will see what we can do directly from Visual Studio.
 
Lets right click on one website and select View Settings. You will be amazed to see the options which is opened in your right panel. Lets explore one by one now.
image
First one you would see is the Stop Website and Restart Website. If the website is in the stopped state you will find an option Start Website in place of Stop Website. As you are aware you stop the application inn windows Azure as well same like the way you do it in IIS.

I believe nothing more to explain this feature as it has got its literal meaning.

Next options which shows under Website Settings are mainly for debugging.

First option is definitely the Framework version. You will have two options either V4.5 or V3.5

image
You may choose the framework version depends on the one you want to run your application.

Next four settings are related to remote debugging.
1. Web Server Logging
2. Detailed Error Messages
3. Failed Request Tracing
4. Application Logging (File System)
5. Remote Debugging

You may enable all or the require logging options in case you are facing any issues with the application. It is very easy to know what exactly is the issue your application is facing by going through this log files. As soon as you change this logging options it will reflect in Windows Azure as well. Which means instead of logging-in to your windows Azure  account you may manage all these options from Visual Studio itself.

I will be stopping today, there are much more to explain about the log files which you are going to get by enabling this logging mechanism.

I will be writing a separate articles for each logs.
Thanks a lot of reading my article.

Thursday, February 12, 2015

Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Recently when I was debugging my application I got the error “Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Below is the exact error I have received.

Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

image
I was very mush sure that I have proper permission in my system and also I am running Visual Studio in Administrator mode. So there is no way I should get security exception.

First thing I checked was the TRUST level in web.config but found that it was set to FullTrust. They suddenly I realized that I am running the code from remote share, I mean from the network drive.Therefore, the remote share that holds the Web applications content requires FullTrust.

There are two ways to solve this error,

1. Copy the complete code in your local drive and run, since you are an administrator to your system there won’t be any issues.

2. Provide FullTrust to your network drive. To provide FullTrust to your network drive you have to follow certain steps. This steps are already documented in Microsoft KB article. I would like you to go through this steps in case if you are interested to provide FullTrust to your network drive.

I hope you are able to resolve this issue now and you are able to debug your application without any problem.

Thanks for reading my article. Please rate the article by clicking on the buttons below.