Showing posts with label .Net. Show all posts
Showing posts with label .Net. Show all posts

Wednesday 20 July 2016

Installing Asp.net Core


Steps To Install Asp.net Core

   

Step 1. Before Installing Asp.net Core Let Fulfill Its Prerequisites As Below -

First you need to Install Visual Studio 2015 . You Can Download Free Visual Studio Community Edition From Link below -
Download Visual Studio 2015

For Mac & Linux Users You Can Use Visual Studio Code -
Download Visual Studio Code & Read Its All Details 

Step 2. After Download & Installing Visual Studio 2015 you need to make sure you have Visual Studio 2015 Update 3 Installed . You Can Download Visual Studio 2015 Update 3 From Link Below -
Download Visual Studio 2015 Update 3

Real ALL Details About Visual Studio 2015 Update 3 Here -
What's New Added in Visual Studio Update 3

Step 3 -  Please Check Out All Dependencies of Asp.net Core Before Installing it . See All Dependencies of Asp.net Core For All OS -
Dependencies of Asp.net Core

Step 4 - Now Download & Install Asp.net Core From link below -
Download Asp.net Core

Step 5 - Now Asp.net Core is Setup Head Towards Next Post To Make First Sample App in Asp.net Core To Make Ensure its setup Correctly . Link TO Next Post is Below - 

Wednesday 6 July 2016

Object Pooling in Csharp


What is Object Pooling in Csharp ?

Object Pooling is Technique for Efficient Resource Allocation.A Performance Optimization Technique that is based on using Pool of Pre-Allocated Resources Such of Objects For Efficient Resource Allocation . It refers to Reusing of Allocated Memory again and again instead of demanding for more memory as there are chances that more required  memory may be not available at runtime (In Running Application) 

Why We Need Object Pooling & How It Works?

Have you Heard about Car Pooling ? Let me tell you about that . Car Pooling and Object Pooling is based on Same Concept . 

Both are based on Re-using / Proper Utilization of Resource . Instead of Having or using new Resource Each Time We Require . 

In Car Pooling We Use Same Resource Car for Multiple Person Instead of Using Car for Each Person . If 4 Person are going to office instead of going from their own car . Car Pooling Tells to Use one car For all 4 People That will save various Natural Resource and money .

Similarly In Object Pooling Memory is assigned to Program Execution and When more objects are required to initialized then instead of demanding and getting more memory resources it waits for previous memory block to get free to be used .

Didn't Got it Don't Worry See Below  


Real Time Example of Object Pooling  ?

Problem :
Let’s assume we are running an application which needs allocation of memory for its execution and this application is using Multithreading. This means more than one threads can allocate the same amount of memory simultaneously . 

Consider that the application needs 100K memory for its execution and there are 50 threads running simultaneously. All 50 threads will call a method of the application simultaneously.

All the threads will try to allocate 100000 bytes in the heap simultaneously. The OS may not get enough time to swap pages. Thus the application will be under heavy concurrent access, and the application may fail due to misleading memory management!

Solution :

WE can also create a pool of large Memory Block as much we can according to how much memory we require, at startup. That way, say we create 100 times 100K bytes in memory at startup. If it fails, well enough - we know that right at startup! So there is no surprise at runtime, when the application is live! So we can reduce that number to 75 (from 100) and try again to start our application. Once up and running, we know that there will be barely a need for it to allocate more memory at runtime, as we already have the memory for 75 or 100 arrays allocated. It just uses that as "an object pool", pulls from it, and when done, returns the byte arrays for subsequent use. Chances are that unless truly "concurrent", the already allocated byte arrays will be re-used over and over again, and at runtime, no extra memory will be allocated. If all 75 or 100 arrays are in use, and a 101st request comes in, it will need to allocate an additional memory of only one array - which is easy for the OS to manipulate in RAM.

Still Din't Got Don't Worry Feel Free! To Comment  

Tuesday 28 April 2015

ASP.NET MVC Action Return View Not Changing URL

The return View(.......) in Action of Controller is the statement that we use to return the view View for a Particular Controller Request . But Return view will return the view exactly you want and render the view but it will not change or target the user to target url  . The simple solution is below -


Code For an Action -

[HttpPost]
public ActionResult Start(SomeViewModel someViewModel)
{
  ...
  return RedirectToAction("SomeOtherAction");

              
                             or


  return RedirectToAction("Action Name", "Controller Name");
}

So , In code above We are using RedirectToAction instead of using  return view this can be used in total of 6 variants .

I have give 2 of simple one . In Parameter to these actions you need to pass the controller and action name according to variant you choose


Wednesday 11 February 2015

HTTP Error 500-22 - Internal Server Error The page cannot be displayed because an internal server error has occurred



Now At 11:47 PM I am going to write about how to solve HTTP 500.22 - Internal Server Error . This error is really very Bad Boy . It only display Error Message and does not give any detailed information about error as we don't normally allow for that . So Now I am going to give information how today Solved this error and what will be sure short and easy steps to solve this error so that you save your time .

I First tried to set CustomErrors="Off" in web.congig file just after <system.web> tag start But it does not helped so first i need to find way to see the error . So only way to see the error is through log file . I was using azure so I decided to turn on azure logging to check what is error

Enable Logging In Microsoft Azure Portal -


- Enable Application Diagnostics Logging 


1. Login to Azure Portal . In sidebar click on websites . Click on desired website
2. Now click on configure In Top Menu and scroll down and find 'Application Diagnostics'
3. Once found Do configuration as shown below -

Application Diagnostics For Application Logging - Windows Azure
Application Diagnostics For Application Logging - Windows Azure

- Enable Web Server Logging 


1. Login to Azure Portal . In sidebar click on websites . Click on desired website
2. Now click on configure In Top Menu and scroll down and find 'Web Server Logging'
3. Once found Do configurations as shown below -

Web Server Logging - Windows Azure
Web Server Logging - Windows Azure

4. After Doing Both Diagnostics Configuration . you must Save and Restart Azure Website .

How To Find Error In Azure Website Log


1. Now after Enabling Log you can see your log by logging in your FTP Client like CuteFTP or      FileZilla( In my case) . First login to your FTP Client of that website

2. Now at root you can see a folder named LogFiles as shown below -

LogFile In windows Azure
LogFile In windows Azure


3. Open the folder and then find a folder named 'DetailedErrors' Now open the folder here you can 4. see all your errors details for that particular website . as shown below -



Azure Website Log File Detailed Errors
Azure Website Log File Detailed Errors


5. So choose the latest file and download it to your computer and open it in browser and It will show you error in your azure website in Detail so that we can know error information to solve the error . In my case error was HTTP Error 500.22 error as shown by log file below snapshot -


Find Error Using Logs in windows Azure
Find Error Using Logs in windows Azure


 Cause of  HTTP Error 500-22 - Internal Server Error


The Main cause of  "HTTP Error 500-22 - Internal Server Error  The page cannot be displayed because an internal server error has occurred" is Managed Pipeline Mode in Application Pool . Integrated Pipeline Mode of Application Pool does not support some services and functionalities 

Solution For HTTP Error 500-22 - Internal Server Error  


Step 1- Change Application Pool From Integrated Pipeline Mode To Classic Pipeline Mode


FOR IIS USERS ON Windows Server


1. Open Control Panel Then GoTo Administrative Tools
2. Then choose IIS Manager
3. Now Change  App site's Managed Pipeline from Integrated to Classic.

FOR AZURE PORTAL USERS 


1. Login to your Azure Portal . In sidebar click on websites . Click on desired website
2. Now click on configure In Top Menu and Under General Section find 'Managed Pipeline Mode'
3. Once Found Change mode from Integrated To Classic Pipeline Mode  as shown in snapshot below

Enable Classic Pipeline Mode Application Pool IIS and Windows Azure
Enable Classic Pipeline Mode Application Pool IIS and Windows Azure

Now after this change No other change will be required Everything is solved now . browse your website everything will be fine .

In case you face some Problem or Same Error Persist You may try the following solutions that can help in resolving issue 

 Changes in Web.Config File (Optional )


1. First open your Web.Config file and Search for <Configuration> Tag opening part and then insert following code in it and it should look like below --

<configuration>
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
    </system.webServer>
</configuration>

Sunday 25 January 2015

Crud Operation in AngularJS With Bootstrap


In My Previous Article I explored about How to setup angularjs in Visual Studio and also Explored concepts of What , why and when To use AngularJS . In this article I am going to do CRUD Operation in AngularJS . CRUD operations means Insert , view , Update and Delete Data In Database . CRUD operations are most important thing that you must practice to create Applications either simple or complex in AngularJS or in any other Language or Technology . I am giving a simple code and easy sample that you can use to Perform CRUD operations in AngularJS using .NET technology 

Download the Sample Code from Link Below .

Download Code



How to setup/Run this sample 


1. First Download the code 
2. Then Open Web.config file and update the connection string to your sqlserver connection string by first making database in you sql server .
3. You need to Deal with CODE First Data migration Commands you can see these command in  link below :-

Data Migration


Snapshots

View Data From Database AngularJS

Insert Data In Database AngularJS

Delete Data from Database AngularJS

Update Data From Database AngularJS

Why we should use AngularJS

What is AngularJS

Why Its Called AngularJS

Why To Use AngularJS

When To Use AngularJS

So , Today i started to explore the top-most question that always stuck our mind when we start with new technology . Like i already know my stuff then when i started with angular these above are basic questions that stuck my mind that what is angularjs and why i should use it and when  .

Today briefly I am going to give answers to these questions -

What is AngularJS ?

AngularJS is a javascript framework developed by Google's Employees . What so special about angularjs is it is client side . what all you need is Javascript and any programming language of your own choice to start with AngularJS that makes angular best . Like in my case I am Asp.net C# developer so I use my all logic like database connectivity in c# and all bindings are done by Angularjs and Let me tell you it is so fast in case of Searching and other type of operations required in Applications developement this is because everything in here is through javascript which is client side It has all inbuilt functions for different type of work that make it suitable for web development .

Why Its Called AngularJS ?

Now foremost question is why its called AngularJS this is because its main Namespace is ng and that sounds like Angular and JS is used with it that's why its called AngularJS .

Why To Use AngularJS

5 Main Points Why we should use AngularJS -

  1. Angular Provides Data-Binding:- binding is the coolest concept in AngularJS. It's a fascinating real-time concept. Just like desktop application, mobile apps user also wishes to witness swift changes in the UI. So AngularJS’ two-way data binding handles the synchronization between the DOM and the model, and vice versa. As a result, the UI changes based on other input components are very much smooth without any extra effort on the part of the developer
  2. Angular Enables Single Page Apps :- Single Page Applications are becoming more popular for a good reason. They fill a very specific need. More functionality is being moved to the web, and the browser is finally realizing its potential as a distributed computing node. By design, SPA applications are far more responsive (even though some of that is perception). They can provide an experience that feels almost like a native app in the web. By rendering on the client they cut down load on the server as well as reduce network traffic – instead of sending a full page of markup, you can send a payload of data and turn it into markup at the client. Of course, Angular doesn't force you into building a SPA app, it only provides plenty of built-in support
  3.  Angular Provides Dependency Injection :- AngularJS has a built-in dependency injection subsystem useful for developers as it makes application development easier including testing. Dependency Injection (DI) allows users to ask for dependencies, rather than having to go and look for them or make them on their own .

    for example, “Hey I need X’, and the DI is responsible for creating and providing it for you. If user wants to gain access to core AngularJS services, all they need to do is add service as a parameter. AngularJS will detect that users need that service and will provide it instantly.
  4.  AngularJS Directives :- Directives can create custom HTML tags that serve as new and custom widgets.Directives achieve this by allowing users to invent their own HTML elements. Putting DOM manipulation code into the directives makes it easy for the users to separate them out of MVC app and leaves MVC to update the view with new data, but how the view will behave is certainly up to directives
  5. AngularJS requires less coding :- The data-binding feature allows developers to stop providing data manually into the view. Filters allow you to manipulate the data on the view level without changing your controllers. As a result, developers need to write very little code to achieve the task, which is a great deal for the developers

     When To Use AngularJS ?

    AngularJS is a very good SPA framework. If we want to create a SPA application, then AngularJS is a good option for it.“SPA” refers to Single Page Application. A Single Page Application is one in which we have a shell page and we can load multiple views into that. So a traditional app, as you know you typically blink and load everything again.
    It’s not very efficient on the bandwidth, especially in the mobile world. In a SPA, we can load the initial content upfront and then the different views or the small kind of mini web pages can be loaded on the fly and embedded into the shell.

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

Setting up Angularjs in Visual Studio Express

AngularJS is a unique framework that without doubt will shape the web development space in the years to come . AngularJS is a recent addition to the client-side MVC frameworks list, yet it has
managed to attract a lot of attention, mostly due to its innovative templating system, ease of  development, and very solid engineering practices

In Simple Words I would say AngularJs is Awesome that anything else .

AngularJS is a relatively new actor on the client-side MVC frameworks scene; its 1.0 version was released only in June 2012. In reality, the work on this framework started in 2009 as a personal project of Miško Hevery, a Google employee. The initial idea turned out to be so good that, at the time of writing, the project was offiially backed by Google Inc., and there is a whole team at Google working full-time on the framework.

AngularJS is an open source project hosted on GitHub (https://github.com/angular/angular.js) and licensed by Google, Inc. under the terms of the MIT licens



Setting Up Angularjs in Visual Studio

1. First Open Visual Studio then Click on Tools Menu
2. Then Under Tools Menu click on Extension and Updates
3. It shows Extension and Updates Window . Now in Search Box at Top right side Typein AngularJS and Hit Enter .
4. Now you will be shown the result as below screenshot -

Add caption

 5. Now click on Install button to Install Angular js in visual studio .
 6. If any of Nuget packages are missing then these will be dependencies for angular that will automatically installed . as shown in screenshot below -


7. Now to check AngualarJS is installed click on File menu then click on New then click on Project
Now  under Templates -> Web category you can see AngularJS installed as shown in screenshot below -


Now AngularJS is ready in Visual Studio .