Making Use Of Bitbucket For Git in Visual Studio

Get connected to a Bitbucket from Visual Studio 2017 and use Git features to create and clone a repository, commit, create and merge branches and create and use all requests.

Making Use Of Bitbucket For Git in Visual Studio

Knowing that many of you are Visual Studio users, in this article, we shall discuss how to create a Bitbucket account, how to add an extension to Visual Studio and how to use various Bitbucket commands like, commit, commit and push, commit and sync, pull request, merge etc. with the help of Visual Studio 2017.

An Overview

Bitbucket is an Atlassian tool for source and version control. It makes use of either Mercurial or Git. It is a web-based service which is available for free up to the maximum five users (very similar to Visual Studio Team Services or VSTS). Bitbucket is also available on-premises.

Bitbucket supports Git which is a decentralized version control system.

With a decentralized version control system, every user could work with his/her own working copy without putting any impact on any other installations on the cloud. Each user can maintain their own repository that has all the versions of the software that is under development and when required, merging with other repositories is possible. There is no requirement of a network as every user is working with a local working copy.

Bitbucket is useful as it gives you as several private repositories as needed. These repos are free, Git gives us a number of public repositories, but not private.

If you are looking for open source development, you need to choose git with Github. Bitbucket provides all the features that git supports.

Bitbucket also provides project management tools as it comes as a part of Atlassian products. Integration to Jira is also available. Bitbucket offers shared repositories amongst team members who are working on a project.

In any case, if the teams use centralized version control system and shift to distributed version control system, they do have a steep learning curve.

Atlassian Bitbucket Server is the Git repository management solution for enterprise teams. It allows everyone in your organization to easily collaborate on your Git repositories.

This page will help you through the basics of Bitbucket Server. By the end you must know how to:

  • Create accounts for collaborators, and organize them into groups with permissions.
  • Develop a project and set up permissions.
  • Develop repositories, and know the simple commands for interacting with them.

Assumptions

This guide imagines that you don’t have earlier experience with Git. But we could assume that:

  • You have Git version 1.7.6 or higher on your local computer.
  • You are making use of a supported browser.
  • You have Bitbucket Server installed and running. If you haven’t, you must take a look at getting started.

Please do refer Git resources for tips on starting with Git.

The first thing you could do in Bitbucket Server is to add collaborators.

To add users in Bitbucket Server

  1. Go to the Bitbucket Server admin area by clicking the cog, then click Users in the Admin screen(under Accounts):
  2. Click Create user to visit directly to the user creation form.
  3. Once you’ve created a user, click Change permissions to make a set up of their access permissions.

There are 4 levels of user authentication:

  • System Admin— can access all the configuration settings of the Bitbucket Server.
  • Admin — same as the System Admins, but they can’t modify file paths or the Bitbucket Server settings.
  • Project Creator — can develop, edit and delete projects.
  • Bitbucket Server User — active users who can access Bitbucket Server.

Keep coding!

And do refer Microsoft’s site to gain more information.

If you want to improve your skill in Dot Net Course and excel yourself in Dot NET training program; our institute, CRB Tech Solutions would be of great help and for you. Come and join us with our well-structured program for the best Dot Net Course. Among many reputed institutes, CRB Tech has craved its niche among the best dot net institutes.

Stay connected to CRB Tech .for more technical optimization and other updates and information.

Don't be shellfish...Buffer this pageEmail this to someoneDigg thisShare on FacebookShare on Google+Share on LinkedInPrint this pageShare on RedditPin on PinterestShare on StumbleUponTweet about this on TwitterShare on Tumblr

What is manifest in .Net?

Manifest maintains information regarding assemblies which include name locale, version and an optional strong name that identifies the assembly. The manifest information is made used by the CLR. The manifest also has the security demands to verify this assembly. It also has the names and hashes of all the files that make up the assembly.

Manifest in .Net Framework

The .NET assembly manifest has s a cryptographic hash of several modules in the assembly. And when the assembly is loaded, the CLR recalculates the hash of the modules at hand, and compares it with the embedded hash. If the hash produced at runtime is different from that in the manifest, .NET refuses to load the assembly and puts an exception.

Manifest explains a relationship and dependencies of components in the assembly.

The versioning information, scope information and the security permissions are needed by the assembly.

An Assembly data like version, security information, scope,etc. is kept in manifest.

The manifest has a reference to the classes and resource.

The manifest is located in an .exe or a .dll with Microsoft intermediate language (MSIL) code.

This file has metadata about .NET assemblies.

It has a collection of data that explains how the elements in the assembly are related to each other.

Place of storage
It could be stored in Portable Executable (PE) file (.exe or .dll) with Microsoft Intermediate Language(MSIL) code.

You could add or change some information in the Assembly Manifest with the help of assembly features in your code.

You can see the manifest information for any managed DLL using ILDasm.

It performs the following functions:

– It lists the files that constitute the assembly.

– It gives a level of lack of straightforwardness between consumers of the assembly and the assemblies implementation details.

– It makes the assembly self-describing.

– It lists other assembly on which the assembly depends.

Summary

A manifest contains all the metadata needed to specify the assembly’s version requirements and security identity and all metadata required to define the scope of the assembly and overcome references to resources and classes.

Assembly name: It is the text string that specifies an assembly’s name. Version number: A major and minor version number, and a revision and build number. The CLR uses these numbers to impose version policy.

Culture: Information on the culture language the assembly supports. This information must be used only to designate an assembly as a satellite assembly containing culture- or specific language information.

Information about reference assemblies: A list of other assemblies that are statically referenced by the assembly. Each reference has the dependent assembly’s name, assembly metadata (version, culture, operating system, and so on), and public key, if the assembly is strong named.

Keep coding!

And do refer Microsoft’s site to gain more information.

If you want to improve your skill in Dot Net Course and excel yourself in Dot NET training program; our institute, CRB Tech Solutions would be of great help and for you. Come and join us with our well structured program for the best Dot Net Course. Among many reputed institutes, CRB Tech has craved its niche among the best dot net institutes.

Stay connected to CRB Tech for more technical optimization and other updates and information.

You may also like:

10 Entity Framework: 7 Features That You Should Know
The simplest way to reconstruct .Net Framework
Don't be shellfish...Buffer this pageEmail this to someoneDigg thisShare on FacebookShare on Google+Share on LinkedInPrint this pageShare on RedditPin on PinterestShare on StumbleUponTweet about this on TwitterShare on Tumblr

ASP.NET Master Pages & Its Advantages

ASP.NET Master pages help you create a fixed layout for pages in your application. A single master page tells about the look and feel and standard behavior that you want for all of the pages in your application.

ASP.NET-Master-Pages

Working with Master Pages

Master pages have two parts, the master page itself and one or more content pages.

Master Page

A master page is an ASP.NET file with the extension .master with a predefined layout that can include static text, HTML elements, and server controls. The master page is defined by a special @Master directive that replaces the @Page directive which is used for ordinary .aspx pages.

The @Master directive has most of the same directives that a @Control directive could contain.

In addition to the @Master directive, the master page also has all of the top-level HTML elements for a page. You can use any HTML and ASP.NET elements as part of your master page.

Replaceable Content Placeholders

In addition to the static text and controls that will appear on all pages, the master page also includes one or more ContentPlaceHolder controls. These define regions where replaceable content will appear. In turn, the replaceable content is defined in content pages. After you finished defining the ContentPlaceHolder controls, a master page might look like the following.

C# / VB

<%@ Master Language=”C#” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML

1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml” >

<head runat=”server” >

<title>Master page title</title>

</head>

<body>

<form id=”form1″ runat=”server”>

<table>

<tr>

<td><asp:contentplaceholder id=”Main” runat=”server” /></td>

<td><asp:contentplaceholder id=”Footer” runat=”server” /></td>

</tr>

</table>

</form>

</body>

</html>

Content Pages

You define the content by developing the individual content pages, which are ASP.NET pages that are bound to a specific master page. The binding is established in the content page’s @Page directive by including a MasterPageFile feature that points to the master page to be used.

In the content page, you develop the content by adding Content controls and tracing them to ContentPlaceHolder controls on the master page.

How to Replace placeholder content

After creating Content controls, you add text and controls to them. In a content page, anything that is not inside the Content controls results in an error. You could perform any tasks in a content page that you would do in an ASP.NET page. For example, you can produce content for a Content control by using server controls and database queries or other dynamic mechanisms.

A content page would look like this:

VB

<% @ Page Language=”VB” MasterPageFile=”~/Master.master” Title=”Content Page 1″ %>

<asp:Content ID=”Content1″ ContentPlaceHolderID=”Main” Runat=”Server”>

Main content.

</asp:Content>

<asp:Content ID=”Content2″ ContentPlaceHolderID=”Footer” Runat=”Server” >

Footer content.

</asp:content>

[C#]

<% @ Page Language=”C#” MasterPageFile=”~/Master.master” Title=”Content Page 1″ %>

<asp:Content ID=”Content1″ ContentPlaceHolderID=”Main” Runat=”Server”>

Main content.

</asp:Content>

<asp:Content ID=”Content2″ ContentPlaceHolderID=”Footer” Runat=”Server” >

Footer content.

</asp:content>

The @Page directive binds the content page to a definite master page, and it defines a title for the page that will be merged into the master page. To be noted that the content page has no other markup outside of the Content controls.

You could create multiple master pages to define different layouts for different parts of your site, and a different set of content pages for each master page.

Advantages of Master Pages

They provide functionality that programmers have always created by copying existing code, or text, and control elements; and so on. Advantages are listed here:

  • They help you to centralize the common functionality of your pages such that you could make updates in just one place.
  • They make it easy to create one set of controls and code and apply the results to a set of pages.
  • They give you fine control over the layout of the final page by permitting you to control the placeholder controls.
  • They provide an object model which allows you to tailor the master page from separate content pages.

Run-time Behavior of Master Pages

At run time, master pages are managed in the following sequence:

  1. Users call for a page by typing the URL of a content page.
  2. The page being fetched, the @Page directive is read.
  3. The master page with an updated content is merged into the control tree of the content page.
  4. The content of individual Content controls is merged into the corresponding ContentPlaceHolder control in the master page.
  5. The resulting merged page is sent to the browser.

From a user’s perspective, the combined master and content pages is a single, discrete page. The URL of the page is that of the content page.

From the programming point of view, the two pages act as separate containers for their respective controls. The content page acts as a container for the master page. You can refer to public master-page members from code in the content page, as described in the next section.

To remember that the master page becomes a part of the content page. In effect, the master page acts in a similar way like a user control acts, as a child of the content page and as a container within that page. In the present case, the master page is the container for all of the server controls that are sent to the browser. The control tree for a merged master and content page looks like this:

Page

Master Page

(Master page markup and controls)

ContentPlaceHolder

Content page markup and server controls

(Master page markup and controls)

ContentPlaceHolder

Content page markup and server controls

(Master page markup and controls)

Paths of Master Page and Content Page

When a content page is called for, its content is merged with the master page, and the page runs in the context of the content page. For instance, if you get the CurrentExecutionFilePath property of the HttpRequest object, whether be in content page code or in the master page code, the path depicts the location of the content page.

The master page and content page don’t need to be in the same folder. As long as the MasterPageFile feature in the content page’s @Page directive resolves to a .master page, ASP.NET can merge the content and master pages into a single rendered page.

External Resources

Both the content page and the master page can have controls and elements that refer external resources. For instance, both might contain image controls that refer image files, or they might contain anchors that refer other pages.

Server Controls

In server controls of master pages, ASP.NET modifies the URLs of properties that refer external resources. At the run time, ASP.NET will modify the URL such that it resolves correctly in the context of the content page.

ASP.NET can modify URLs in the following situations:

  • URL being a property of an ASP.NET server control.
  • The property is referred internally in the control as being a URL. Practically, ASP.NET server control properties that are commonly used to refer external resources are marked in this way.

Master Pages and Themes

You can’t apply directly an ASP.NET theme to a master page. If you add a theme feature to the @Master directive, the page will raise an error when it runs.

However, themes could be applied to master pages under these circumstances:

  • If a theme is defined in a content page.
  • If the site as a whole is configured to use a theme by including a theme definition in the pages Element (ASP.NET Settings Schema) element.

How To Scope Master Pages

You can attach content pages to the master page at 3 levels:

  • At the page level: You could use a page directive on each content page to bind it to a master page.
  • At the application level:By making a setting in the pages element of the application’s configuration file (Web.config), you can specify that all ASP.NET pages (.aspx files) in the application automatically bind to a master page.

If you use this strategy, all the ASP.NET pages in the application that have Content controls are merged with the mentioned master page.

Keep coding!

And do refer Microsoft’s site to gain more information.

If you want to improve your skill in Dot Net Course and excel yourself in Dot Net Training; our institute, CRB Tech Solutions would be of great help and for you. Come and join us with our well-structured program for the best Dot Net Course. Among many reputed institutes, CRB Tech has craved its niche among the best dot net institutes.

Stay connected to CRB Tech for more technical optimization and other updates and information.

You May Also Like: 

What Are The Differences Between ASP and ASP.NET?
How to Improve Performance of Asp.net Website?

Don't be shellfish...Buffer this pageEmail this to someoneDigg thisShare on FacebookShare on Google+Share on LinkedInPrint this pageShare on RedditPin on PinterestShare on StumbleUponTweet about this on TwitterShare on Tumblr

What Are The Differences Between ASP and ASP.NET ?

This article has a list of differences of the ASP.NET technology and the classic ASP technology. Hope it is well informative to you.

ASP Vs ASP.Net

You will see many articles on the Internet where in you came across the differences. These articles are jumbled all over the websites. Here is a compilation of all the ideas to provide a better understanding on their differences.

Process Isolation

ASP is run under the inetinfo.exe (IIS) process space and is susceptible to crashes as a result the IIS requires to be stopped or restarted. ASP is related to process isolation setting in IIS.

Whereas, ASP.Net worker process is a distinct worker process, aspnet_wp.exe, totally different from inetinfo.exe (IIS process), and the process model in ASP.NET is not related to process isolation settings in the IIS.

Non-MS Platform Support

Classical ASP has no mechanism of running itself on non MS technology platforms like the ‘The Apache Web Server’. Whereas, ASP.NETcould be run on non-MS Platforms as well. Cassini is a sample Web server produced by MS which, among other projects, which has been used to host ASP.NET with Apache.

Multi Language Support in WebPage

In ASP ,only 2 languages were available for scripting VBScript and Jscript/Javascript.

While in ASP.NET, you no longer need to constrain for the two scripting languages available in conventional ASP: Any completely compliant .NET language can now be used with ASP.NET, including C# and VB.NET.

Other differences are mentioned below:

ASP :

i. It has a very limited OOPS support and no in built support for XML.

ii. It has quite a less development and debugging tool.

iii. With, ASP you could only do scripting with visual basic scripting and java scripting.

iv. Very poor error handling.

v. It has no high level programming structure.

vii. It has no in built validation control, hence any validating page is difficult for developers.

viii. In a classic ASP if you need to update code on an existing page, it is mandatory to restart the server to get reflect.

ASP.NET

i. ASP.NET is completely object oriented programming.

ii. It has full support of XML.

iii. Various tools and compilers are available. MS Visual studio helps you in debugging.

iv. It can use either C# or VB.NET as server side programming language.

v. ASP.NET gives you 3 tire architecture. It allows you to keep your business logic and views separate. It helps to enhance applications.

vi. Error handling is quite good.

vii. It has a “state” management support.

viii. In built validation controls are present.

These are the main differences between classic ASP and ASP.NET. Hope this is helpful to you.

Keep coding!

And do refer Microsoft’s site to gain more information.

If you want to improve your skill in Dot Net Course and excel yourself in Dot NET training program; our institute, CRB Tech Solutions would be of great help and for you. Come and join us with our well structured program for the best Dot Net Course. Among many reputed institutes, CRB Tech has craved its niche among the best dot net institutes.

Stay connected to CRB Tech for more technical optimization and other updates and information.

You May Also Like :

Five Methods To Deal with Errors In ASP .Net 
2 Points To Remember in ASP .NET 
Don't be shellfish...Buffer this pageEmail this to someoneDigg thisShare on FacebookShare on Google+Share on LinkedInPrint this pageShare on RedditPin on PinterestShare on StumbleUponTweet about this on TwitterShare on Tumblr

What Do You Understand By HTTP Handlers and HTTP Modules

When a client calls a request for a resource located on the server in an ASP.NET application, each request is managed by the HTTP Handlers. Microsoft ASP.NET has a number of in-built HTTP Handlers which serves different files like .ASPX, .ASMX etc. Based on the extension of the file, the appropriate HTTP Handlers gets loaded which is mapped to the extension and is responsible for processing the ASP.NET request.

Dot Net HTTP Handlers and HTTP Modules

 

Custom HttpHandlers

You could also create your own custom HTTP Handlers and register it for request handling. You could register the HTTP Handlers in a Web.Config file using <HttpHandlers /> element. However, the registration will always be based on the version of IIS.

Let’s develop a small instance of custom HTTP Handlers. You can device a custom HTTP Handler using a simple class which implements an interface IHttpHandler. This interface offers one method ProcessRequest() and a property IsReusable.

  • ProcessRequest() – A method which gets requested when a request is received. Inside this method, you could call the HttpContext object that is passed as a parameter to the method. Using this object you can access the Request, Response and Server objects for implementing the processing logic.

  • IsReusable Property – When this handler is requested, the ProcessRequest method will process it. If the IsReusable property is set to true, the same handler will be used for processing other requests of the same type. If it is false, then after the request is processed, the handler object gets destroyed.

Let’s develop a custom handler as shown below -

public class CustomHandler:IHttpHandler

{

public bool IsReusable

{

get { return false; }

}

public void ProcessRequest(HttpContext context)

{

context.Response.Write(“<h1 style=’Color:#000066′>WelCome To Custom HttpHandler</h1>”);

context.Response.Write(“HttpHandler processed on – “ + DateTime.Now.ToString());

using (StreamWriter SW=new StreamWriter(@”E:\HandlerMessages.txt”,true))

{

SW.WriteLine(“The message date time is – “ + DateTime.Now.ToString());

SW.Close();

}

}

}

Now let’s configure our custom HttpHandler into Web.Config file as shown below -

<httpHandlers>

<add verb=”*” path=”*.curry” type=”CustomHandlerModuleExample.CustomHandler”/>

</httpHandlers>

Now add a simple text file with extension “.curry” and browse the “.curry” extension file.

In other words, an HttpHandler is often associated with a specific extension, and a practical usage includes dynamic image generation or modification.

What is an HTTP Module

Now let’s explore the HttpModule. HttpModule is a part of call, processing of ASP.NET. In a single request processing, there could be more than one modules which gets executed. HttpModules take part in processing of the request by handling the Application events. There are a number of events which you can handle during the HttpModule processing. For example – BeginRequest(), EndRequest(), AuthenticateRequest() etc.

You could also create custom HttpModules. You could design a custom HttpModule using a simple class which implements IHttpModule interface. This interface gives two methods:

  • Init() – This method takes a HttpApplication object as parameter which permits the HttpModule to register the events.

  • Dispose() – The logic of cleanup could be written in this method which will get executed before a garbage collection.

HttpModules can be registered in Web.Config using <httpModules/>

Let’s create a simple HttpModule as shown below which creates a log file on C: -

public class CustomHttpModule:IHttpModule

{

public void Init(HttpApplication context)

{

context.BeginRequest += new EventHandler(this.context_BeginRequest);

context.EndRequest += new EventHandler(this.context_EndRequest);

}

public void context_EndRequest(object sender, EventArgs e)

{

StreamWriter sw = new StreamWriter(@”C:\requestLog.txt”, true);

sw.WriteLine(“End Request called at “ + DateTime.Now.ToString());

sw.Close();

}

public void context_BeginRequest(object sender, EventArgs e)

{

StreamWriter sw = new StreamWriter(@”C:\requestLog.txt”, true);

sw.WriteLine(“Begin request called at “ + DateTime.Now.ToString());

sw.Close();

}

public void Dispose()

{

}

}

Let’s register the custom HttpModule into the Web.Config file as shown below -

<httpModules>

<add name=”DotNetCurryModule” type=”CustomHttpModule”/>

</httpModules>

Now request the same file in a browser “Hello.curry” and check the files on C drive. You will find a requestLog.txt.

In other words, an HttpModule will execute for every call of your application, irrespective of the extension used. Http Modules are mainly used for security, statistics, logging etc.

Keep coding!

Let us know your opinion in the comments sections below. And feel free to refer Microsoft’s site to gather more information.

If you want to improve your skill in Dot Net Course and excel yourself in Dot NET training program; our institute, CRB Tech Solutions would be of great help and for you. Come and join us with our well structured program for the best Dot Net Course. Among many reputed institutes, CRB Tech has craved its niche among the best dot net institutes.

Stay connected to CRB Tech for more technical optimization and other updates and information.

Don't be shellfish...Buffer this pageEmail this to someoneDigg thisShare on FacebookShare on Google+Share on LinkedInPrint this pageShare on RedditPin on PinterestShare on StumbleUponTweet about this on TwitterShare on Tumblr

Popular Error Logging Libraries For .NET

Part I

This article is in continuation with our previous article on the same. The article discuss some effective error handling strategies that you could use in your projects.

Common Error Logging libraries for .NET

For .NET framework, the most popular logging libraries are probably log4net and NLog.

Although, there are differences between the two, the main concepts are similar.

In NLog, for instance, you will basically create a static logger instance in every class that needs to write anything to the log:

private static Logger logger = LogManager.GetLogger(“LoggerName”);

To write to the log, you will simply call a method of that class:

logger.Error(exception.ToString());

As you have noticed, you have not yet specified where you want to log the errors. Instead of hard coding this information in the application, you will put it in the NLog.config configuration file:

<?xml version=”1.0″ encoding=”utf-8″ ?><nlog xmlns=http://www.nlog-project.org/schemas/NLog.xsdxmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”>

<targets>

<target name=”logfile” xsi:type=”File” fileName=”errors.log”

layout=”${date:format=yyyyMMddHHmmss} ${message}” />

</targets>

<rules>

<logger name=”*” minlevel=”Error” writeTo=”logfile” />

</rules>

</nlog>

The above configuration says that all errors will be logged to the errors.log file and accompanied with a timestamp.

But, you can easily specify a different type of target instead of a file or even add additional targets to log the errors to multiple locations.

With the layout feature, you can define which additional metadata you want to log along with the message. Different targets have different additional attributes to further control the logging process, e.g. archiving policy for log files and naming based on current date or other properties.

Using the rules section, you can even configure logging of different errors to different targets, based on the name of the logger that was used to emit the error.

Log levels can add additional flexibility to your logging.

Instead of only logging errors, you can log other information at different levels (warning, information, trace…) and use the minlevel attribute to specify which levels of log messages to write to the log and which to ignore.

You can log less information most of the time and selectively log more when troubleshooting a specific issue.

Analyze Production Log Files

Logging information about errors is the first step.

Based on the logged information, you can detect any problems with the application and act on them, i.e. fix them to ensure that the application runs without errors in the future.

In order to do effectively, the following tips could be helpful:

  • Receive notifications when errors happen
  • Collect similar errors in groups, so that you do not need to check each one of them individually.

As always, there are ready-made solutions for these problems available so that we do not need to develop them ourselves.

A common choice in .NET ecosystem is Application Insights. It is an Azure SaaS (Software as a Service) offering, with a free tier to get us started, and a usage based pricing model.

The product is integrated into VS. There is a wizard present to add Application Insights telemetry to a running project or to a newly created one. It will install the required NuGet package, create an accompanying resource in Azure and link the project to it with configuration entries.

Logged data can be analyzed in Azure Portal or inside Visual Studio.

If you want keep all the information on-premise, there is an open source alternative available: OneTrueError.

Before you start using it, you need to install the server application on your own device.

There is no wizard available for configuring OneTrueError in your application, but the process is simple:

- Install the NuGet package for your project type, e.g. OneTrueError.Client.AspNet for ASP.NET applications.

- Initialize automatic exception logging at application startup, e.g. in ASP.NET applications, add the following code to your Application_Start method (replace the server URL, app key and shared secret with data from your server, of course):

var url = new Uri(“http://yourServer/onetrueerror/”);OneTrue.Configuration.Credentials(url, “yourAppKey”, “yourSharedSecret”);OneTrue.Configuration.CatchAspNetExceptions();

Both Application Insights and OneTrueError solve another problem with log files: large modern applications which has multiple services and are installed on multiple machines for reliability and load balancing.

Each service on each machine creates its own log and to get the full picture, data from all these logs needs to be consolidated in a single place.

By logging to a centralized server, all logs will automatically be collected there with information about its origin.

Error handling specifics for Mobile Applications

Just like Application Insights and OneTrueError provide a complete solution for server application, there are dedicated products available for mobile applications.

Basically, they are not limited to error or crash reporting but also include support for usage metrics and (beta) application distribution.

Microsoft’s associate to Application Insights for mobile and desktop applications is HockeyApp, but there are other alternatives as well, like Raygun and Crashlytics. They have similar attribute set and differentiate themselves by varying support for specific development platforms and pricing models.

Most of them require only a couple of lines of code to get started.

Keep coding!

Let us know your opinion in the comments sections below. And feel free to refer Microsoft’s site to gather more information.

If you want to improve your skill in Dot Net Course and excel yourself in Dot NET training program; our institute, CRB Tech Solutions would be of great help and for you. Come and join us with our well structured program for the best Dot Net Course. Among many reputed institutes, CRB Tech has craved its niche among the best dot net institutes.

Stay connected to CRB Tech for more technical optimization and other updates and information.

Don't be shellfish...Buffer this pageEmail this to someoneDigg thisShare on FacebookShare on Google+Share on LinkedInPrint this pageShare on RedditPin on PinterestShare on StumbleUponTweet about this on TwitterShare on Tumblr

Best Practices In Error Handling in .NET Projects

This article talks about some effective error handling strategies that you can use in your projects.

Best Practices for Exception Handling

The best way to express error conditions in .NET framework is by putting exceptions. In C#, you could handle them using the try-catch-finally statement:

try

{

// code which can throw exceptions

}

catch

{

// code executed only if exception was thrown

}

finally

{

// code executed whether an exception was thrown or not

}

Whenever an exception is put inside the try block, the execution occurs in the catch block. The finally block executes after the try block is complete successfully. It also executes while exiting the catch block, either successfully or with an exception.

In the catch block, you need information about the exception we are handling. To do it, you use the following syntax:

catch (Exception e)

{

// code can find exception details in variables

}

The type used, specifies which exceptions will be caught by the catch block.

You can add multiple catch blocks to a single try block. In this case, the exception will be caught by the first catch block with matching exception type:

catch (FileNotFoundException e)

{

// code will only handle FileNotFoundException

}

catch (Exception e)

{

// code will handle all the other exceptions

}

This helps to handle different types of exceptions in multi ways. You can recover from expected exceptions in a very specific way, for instance:

  • If a user selects a non-existing or invalid file, he will be allowed to select a different file or cancel the action.
  • If a network operation timed out, he can retry it or invite the user to check his network connectivity.

For remaining unexpected exceptions, e.g. a NullReferenceExceptions caused by a bug in the code, you can show the user a generic error message, giving him an option to report the error, or log the error without any user intervention.

It is at times very important to avoid swallowing exceptions silently:

catch (Exception e)

{ }

Doing this is bad for either the user or the developer.

The user might assume that an action succeeded, where it silently failed or did not complete; whereas the developer will not get notified about the exception, and he would not know that he might need to fix something in the application.

Hiding errors silently are only appropriate in very rare scenarios, for instance, to catch exceptions put when attempting to log an error in the handler, for unexpected exceptions.

Centralized Exception Handling

When writing exception-handling code, it is essential to do it in the right place. You might be tempted to do it as close to the origin of the exception as possible, e.g. at the level of each individual function:

void MyFunction()

{

try

{

// actual function body

}

catch

{

// exception handling code

}

}

This is appropriate for exceptions which you can handle in programs, without any user interaction. This is in cases when your application can fully recover from the exception and still successfully complete the requested operation, and therefore the user does not require knowledge that the exception occurred at all.

But, if the requested action failed because of the exception, the user must know about it.

In a desktop application, it would be possible to show an error dialog from the same method where the exception occurred, but in the worst case, this could result in a cascade of error dialogs, because the functions might also fail

void UpdatePersonEntity(PersonModel model)

{

var person = GetPersonEntity(model.Id);

ApplyChanges(person, model);

Save(person);

}

Let’s assume an unrecoverable exception is thrown inside GetPersonEntity (e.g., there is no PersonEntity with the given Id):

  • GetPersonEntity will catch the exception and show an error dialog to the user.
  • Due to the previous failure, ApplyChanges will fail to update the PersonEntity with the value of null, as returned by the first function. According to the policy of handling the exception where it happens, it will show a second error dialog to the user.
  • Similarly, Save will also fail because of PersonEntity having null value, and will show a third error dialog in a row.

To avoid the above situations, you must handle unrecoverable exceptions and show error dialogs in functions invoked by a user action.

In a desktop application, these will typically be event handlers:

private void SaveButton_Click(object sender, RoutedEventArgs e)

{

try

{

UpdatePersonEntity(model);

}

catch

{

// show error dialog

}

}

In contrast, UpdatePersonEntity and any other functions must not catch any exceptions that they cannot handle properly.

This works as well in a web application.

In WPF, a global exception handler could be hooked to the application’s DispatcherUnhandledException event:

public partial class App : Application

{

public App()

{

DispatcherUnhandledException += App_DispatcherUnhandledException;

}

 

private void App_DispatcherUnhandledException(object sender,

DispatcherUnhandledExceptionEventArgs e)

{

var exception = e.Exception; // get exception

// … show the error to the user

e.Handled = true;// prevent the application from crashing

Shutdown();// quit the application in a controlled way

}

}

In ASP.NET, the global exception handler is convention based – a method named Application_Error in global.asax:

private void Application_Error(object sender, EventArgs e)

{

var exception = Server.GetLastError(); // get exception

Response.Redirect(“error”);// show error page to user

}

What must a global exception handler do?

From the user standpoint, it must display a friendly error dialog or error page with instructions on how to proceed, for a developer, it is important to log the exception details for further analysis:

File.AppendAllText(logPath, exception.ToString());

Calling ToString() on an exception will return all its details, including the description and call stack in a text format. This is the minimum amount of information you want to log.

To make later analysis easier, you could include additional information, like current time and any other useful information.

Use Of Exception Logging Libraries

Though writing errors to log files might appear simple, there are several challenges to address:

  • Where must files be located?
  • How to organize the log files?
  • How large may the log files grow?
  • Will the application write errors from multiple threads?

There are also alternatives to log files that might be more suitable in certain scenarios:

  • Windows Event Log was created for logging errors and other information from applications. It solves all the above challenges but needs dedicated tooling to access the log entries.
  • If your application already uses a database, it could also write error logs to the database. If the error is caused by the database that’s not accessible, the application will not be able to log that error to the database though.

You do not want to decide on the above choices before hand, but rather configure the behavior during the process of installation.

We conclude for now. We shall discuss some more details about the same, in our next article.

Keep coding!

Let us know your opinion in the comments sections below. And feel free to refer Microsoft’s site to gather more information.

If you want to improve your skill in Dot Net Course and excel yourself in Dot NET training program; our institute, CRB Tech Solutions would be of great help and for you. Come and join us with our well-structured program for the best Dot Net Course. Among many reputed institutes, CRB Tech has carved its niche among the best dot net institutes.

Stay connected to CRB Tech for more technical optimization and other updates and information.

Don't be shellfish...Buffer this pageEmail this to someoneDigg thisShare on FacebookShare on Google+Share on LinkedInPrint this pageShare on RedditPin on PinterestShare on StumbleUponTweet about this on TwitterShare on Tumblr

What’s Brewing for .NET Developers

What is New and Exciting in Microsoft’s Open Dev Ecosystem

.NET Core 1.1

.NET Core 1.1 is the first and new minor version of .NET Core – a cross-platform, opens source, and modular .NET platform for creating modern .NET applications. Unlike the LTS version 1.0, .NET Core 1.1 is categorized as a “Current” release. While LTS releases have a 3-year support period from the original release or 1 year from the next LTS release, the “Current” releases are only eligible for support as long as their parent LTS release or 3 months after the next “Current” release, whichever comes first. The two versions could be safely installed side-by-side, such that individual applications on the same machine can make use of either.

The focus of this release was performance. The big news was that ASP.NET Core is now included in the TechEmpower web framework benchmarks, and is the most rapid mainstream full stack framework in the Plaintext category.

Various new features were added to ASP.NET Core 1.1:

  • MVC filters allow you apply middleware only to specific controllers or actions.
  • Two new middleware are included: URL rewriting and response caching.
  • Web Listener Server for Windows is available as an alternative to Kestrel. With it, you could take benefit of Windows specific features, such as Windows authentication, HTTP/2 over TLS, and others.
  • Compiling views during the publish process is supported.

Entity Framework Core 1. has built-in support for connection flexibility and SQL Server memory-optimized tables. Owing to improved LINQ translation, the database engines can successfully execute more queries than before. New APIs were added for explicit loading, mapping to fields and a few other features.

MSBuild tooling for .NET Core became available in preview. This means that standard .csproj project files can be used instead of project.json. To proper align the two formats, MSBuild now supports wildcard-based inclusion of files for folder based projects, and direct NuGet package references. A wizard for migrating project.json projects to .csproj is included as well.

Visual Studio 2017 Release Candidate

Visual Studio “15” now has its official name: Visual Studio 2017. You can now download Visual Studio 2017 Release Candidate and even use it in production with the exception of features marked as in preview, and are not yet supported.

The new version of Visual Studio comes with many productivity changes:

  • better filtering and default suggestions,
  • easy navigation with redesigned Find All References and Go To functionalities,
  • new Exception Helper dialog with support for filtering exceptions
  • quick reattaching and filtering by process name in the Attach to Process dialog,
  • continuous running of tests and coverage information for individual code lines with Live Unit Testing
  • additional code refactoring,
  • Configurable code style and many more.

Better performance is also a priority: Visual Studio 2017 starts faster, has shorter load times, and a faster, more componentized installer. To further speed-up initial loading of large solutions; lightweight solution loading can be enabled for them, which defers the full loading of projects to a later time when they are first needed.

Extensions can also largely affect the overall responsiveness of Visual Studio. The new performance-supervising feature will now warn the user about extensions which slow down Visual Studio. Other improvements to extensions include:

  • batched installs and updates,
  • built-in roaming extension manager, and
  • support for extensions to find out missing dependencies and trigger their installation in Visual Studio.

A few other new attributes in Visual Studio 2017 that are also worth mentioning:

  • New versions of C# and Visual Basic provide many new language features
  • A new Service Capabilities page is now the centralized location for adding cloud service dependencies to a project.
  • You can record tests for mobile applications using the new mobile test recorder and upload them directly to Xamarin Test Cloud.
  • A preview version of Visual Studio Tools for Unity 3 is now included in the installer. Among other improvements, it adds full syntax colouring and IntelliSense support for Unity event functions.

Visual Studio for Mac

The VS product family got a new member: Visual Studio for Mac. The preview is already available so get it download. The application is an evolved version of Xamarin Studio, more closely aligned to the Visual Studio experience on Windows. It supports development of Xamarin based mobile applications, and their cloud backend in .NET Core, using either C# or F#. It features the same Roslyn powered compiler, IntelliSense code completion and refactoring experience as Visual Studio. The same MSBuild project format allows for seamless sharing of projects between Visual Studio on Windows and Mac.

Visual Studio Tools for Samsung’s Tizen

Tizen is Samsung’s Linux-based open source operating system, used in over 50 million of their devices: smart TVs, wearables, smartphones and IoT devices. At the event, Samsung announced its intention on collaborating with Microsoft to bring .NET Core to ARM devices, and add Tizen support to Xamarin.Forms.

The first preview of Visual Studio Tools for Tizen is already available. It provides an alternative to existing C and HTML 5 based programming models for Tizen. Currently only mobile application development is supported, but other types of devices will follow in the future. All the development is done in C# with.NET Core, Xamarin.Forms for the user interface, and wrappers for many native APIs to access device specific functionalities – everything with full IntelliSense support. Debugging takes advantage of device emulators, which are included in the download.

The official release is planned for 2017, when the .NET Core runtime will also ship to devices.

Summary:

- Microsoft joins the Linux Foundation as Platinum member

- Google joins the .NET Foundation

- Samsung releases VS Tools for Tizen

- Microsoft announces VS 2017

- Visual Studio 2017 will have cross-platform support

- Microsoft announces Visual Studio for Mac

- Microsoft announces Visual Studio Mobile Center

- Microsoft has the most contributors on GitHub

- SQL Server for Linux is now publicly available. SQL Server 2016 Service Pack 1 available.

- Azure Data Lake Analytics and Store

- Azure Functions and N-Series available now. First Cloud Bot-as-a-Service announced.

Microsoft continues to provide a great set of benefits and tools for any developer, any app, and any platform. Since the first Connect(); event in 2014, Microsoft has been using it to announce many important development related releases. From VS 2017 Release Candidate with “go-live license” and VS for Mac Preview to new Xamarin tooling and new .NET Core version, there was something of interest for any developer already working with Microsoft tools or technologies. Microsoft also expands its focus from Windows to other platforms, these announcements have become increasingly interesting to developers who are not in Microsoft’s ecosystem yet.

We conclude for now. Keep coding!!

Let us know your opinion in the comments sections below. And feel free to refer Microsoft’s site to gather more information.

If you want to improve your skill in ASP.Net and excel yourself in ASP.NET training program; our institute, CRB Tech Solutions would be of great help and for you. Come and join us with our well swell-structuredam for ASP .Net.

Stay connected to CRB Tech for more technical optimization and other updates and information.

Don't be shellfish...Buffer this pageEmail this to someoneDigg thisShare on FacebookShare on Google+Share on LinkedInPrint this pageShare on RedditPin on PinterestShare on StumbleUponTweet about this on TwitterShare on Tumblr

Software Development Life Cycle Or SDLC

Software Development Life Cycle Or SDLC : Dot Net

SDLC is a process that must be followed for a software project, within an IT organization. It has a detailed plan that describes how to develop, maintain, replace and enhance the specific software. The life cycle defines a methodology for improving the quality of software and the overall development process.

A typical Software Development life cyclant and fundamental stage in SDLC.

It is done by senior members of the team with inputs from the customer, the sales department, and market analysis and domain experts in the sector. This information is next used to plan the basic project approach and to conduct product feasibility study in the economical, operational, and technical areas.

Stage 1: Stage 1: Planning and Requirement Analysis

Planning for the quality assurance needs and identification of the risks associated with the project is also done in the planning stage. The outcome of the technical feasibility study is to explain the various technical approaches that could be followed to implement the project successfully with minimum risks.

Stage 2: Explaining Requirements

Once the requirement analysis is finished, the next step is to clearly define and document the product requirements and get them approved by the customer. This is done through SRS. Software Requirement Specification document consists of all the product requirements to be developed and designed during the project life cycle.

Stage 3: Designing the product architecture

SRS is the reference for product architects to give the best architecture for the product to be designed. Based on the requirements specified in SRS, usually more, than one design approach for the product architecture is proposed and documented in a DDS – Design Document Specification.

This DDS is reviewed by the important stakeholders and based on several parameters like risk assessment, product hugeness, design modularity, budget and time constraints, the best design approach is selected for the product.

A design approach well defines all the architectural modules of the product along with its communication and data flow representation with the external modules.

Stage 4: Building the Product

In this stage the actual development begins and the product is developed. The programming code is generated as per DDS. If the design is performed in a detailed and organized manner, code generation couild be accomplished without much hassle.

Developers have to follow the coding guidelines given by their organization and programming tools like compilers, interpreters, debuggers etc are used to develop the code.

Different HLL like C, C++, Pascal, Java, and PHP are used for coding. The programming language is chosen based on the type of software being developed.

Stage 5: Test the Product

This stage is the subset of all the stages as in the modern SDLC models, the testing activities are mostly done in all the stages of SDLC. However, this stage refers to the testing only stage where defects are tracked, reported, fixed and retested, until the product gets the quality standard as defined in the SRS.

Stage 6: Deployment in the Market and Maintenance

Once the product is tested and ready to be deployed it is released in the market. Sometime product deployment happens in stages. The product might first be released in a limited segment and tested in the real business environment.

Then based on the feedback, the product might be released as it is or with suggested enhancements in the targeting market segment. After the product is released in the market, its maintenance is done for the existing customer base.

We conclude for now. Keep coding!!

Let us know your opinion in the comments sections below. And feel free to refer Microsoft’s site to gather more information.

If you want to improve your skill in ASP.Net and excel yourself in dot NET training program; our institute, CRB Tech Solutions would be of great help and for you. Come and join us with our well-structured program for ASP.Net. and be a part of the best dot net institute in Pune. We offer best dot net course which is scientifically programmed and keep updating with time.

Stay connected to CRB Tech for more technical optimization and other updates and information.

Don't be shellfish...Buffer this pageEmail this to someoneDigg thisShare on FacebookShare on Google+Share on LinkedInPrint this pageShare on RedditPin on PinterestShare on StumbleUponTweet about this on TwitterShare on Tumblr

Important Interview questions and Answers For ASP.Net MVC

In this article, we shall discuss top ASP.Net MVC Interview questions and answers for fresher and experienced dot net developers. Among many questions, the most important or the ones often asked are discussed here.

1) Define MVC?

MVC is a pattern that is used to split the application’s implementation logic into 3 components: models, views, and controllers.

2) How do you explain Model, Controller and View in MVC?

  • Model – It’s a business entity and is used to represent the application data.
  • Controller – Request sent by a user scatters through the controller and its responsibility is to redirect to the specific view using View() method.
  • View – It’s the presentation layer of MVC.

3) Explain the new features in version 4 of MVC (MVC4)?

Following are the attributes added –

  • Mobile templates
  • Added ASP.NET Web API template to create REST based services.
  • Asynchronous controller task support.
  • To bundle the Java scripts.
  • Segregating the configurations for MVC routing, Web API, Bundle etc.

4) How do you explain the page life cycle of MVC?

Here we mention the processed flow of the sequence -

  • App initialization
  • Routing
  • Instantiate and execute controller
  • Locate and invoke controller action
  • Instantiate and render view.

5) Mention the advantages of MVC over ASP.NET?

  • It offers a clean separation of concerns among UI, model and Business Logic.
  • Easy for UNIT Test.
  • Improve reusability of model and views.
  • Improve structuring the code.

6) What is Separation of Concerns in ASP.NET MVC?

It’s is the method of breaking the program into various distinct attributes which overlaps in functionality as little as possible. MVC pattern concerns on separating the content from presentation and data-processing from content.

8) What is the meaning of Unobtrusive JavaScript?

This is a general term for conveying a general philosophy, similar to the term REST (Representational State Transfer).

Eg: Instead of using events like onclick and onsubmit, the unobtrusive JavaScript attaches to elements by their ID or class based on the HTML5 data- attributes.

9) What is the uage of ViewModel in MVC?

ViewModel is a plain class with properties, that is used to bind it to strongly typed view. ViewModel can have the validation rules defined for its properties using data annotations.

10) What do you mean by Routing in MVC?

Routing is a pattern matching mechanism of incoming requests to the URL patterns which are registered in route table. Class – “UrlRoutingModule” is used for the same process.

11) What are Actions in MVC?

Actions are the process in Controller class which is for returning the view or json data. Action will mainly have return type – “ActionResult” and it will be invoked from method – “InvokeAction()” called by the controller.

12) What is Attribute Routing in MVC?

ASP.NET Web API supports this type of routing. This is introduced in MVC5. In this type of routing, features are used to define the routes. This type of routing gives more control over classic URI Routing. Attribute Routing can be defined at controller level or at Action level as mentioned below–

[Route(“{action = TestCategoryList}”)] – Controller Level

[Route(“customers/{TestCategoryId:int:min(10)}”)] – Action Level

13) How do you enable Attribute Routing?

Simply add the method – “MapMvcAttributeRoutes()” to enable attribute routing as given below:

public static void RegistearRoutes(RouteCollection routes)

{

routes.IgnoareRoute(“{resource}.axd/{*pathInfo}”);

//enabling attribute routing

routes.MapMvcAttributeRoutes();

//convention-based routing

routes.MapRoute

(

name: “Default”,

url: “{controller}/{action}/{id}”,

defaults: new { controller = “Customer”, action = “GetCustomerList”, id = UrlParameter.Optional }

);

}

14) Explain JSON Binding?

JavaScript Object Notation (JSON) binding support started from MVC3 onwards via the new JsonValueProviderFactory, which allows the action methods to accept and model-bind data in JSON format. This is useful in Ajax scenarios like client templates and data binding that need to post data back to the server.

15) Explain Dependency Resolution?

Dependency Resolver again has been introduced in MVC3 and it is greatly simplified the use of dependency injection in your applications. This makes easier and necessary for decoupling the application components and making them easier to test and more configurable.

16) What is Bundle.Config in MVC4?

“BundleConfig.cs” in MVC4 is taken in use to register the bundles by the bundling and minification system. Many bundles are added by default including jQuery libraries like – jquery.validate, Modernizr, and default CSS references.

17) How route table is created in ASP.NET MVC?

Method – “RegisterRoutes()” is used to register the routes which will be added in “Application_Start()” method of global.asax file, which gets fired when the application is loaded or began.

We conclude for now. Keep coding!!

Let us know your opinion in the comments sections below. And feel free to refer Microsoft’s site to gather more information.

If you want to improve your skill in ASP.Net and excel yourself in ASP.NET training program; our institute, CRB Tech Solutions would be of great help and for you. Come and join us with our well structured program for ASP .Net.

Stay connected to CRB Tech for more technical optimization and other updates and information.

Don't be shellfish...Buffer this pageEmail this to someoneDigg thisShare on FacebookShare on Google+Share on LinkedInPrint this pageShare on RedditPin on PinterestShare on StumbleUponTweet about this on TwitterShare on Tumblr