Wednesday

How To Own ASP.Net MVC Page Life Cycle For Free

Introduction

Before to start over to know about MVC complete Life Cycle, it is mandatory to add required namespaces in web.config which are automatically added when we add MVC package in our MVC application. We all know the basic behaviour of MVC is based on HTTP requests. In my recent article, I have already explained how to create amazing charts using MVC.

I have provided all necessary MVC life cycle steps here.
<namespaces> 
<add namespace="System.Web.Helpers">
<add namespace="System.Web.Mvc">
<add namespace="System.Web.Mvc.Ajax">
<add namespace="System.Web.Mvc.Html">
<add namespace="System.Web.Optimization">
<add namespace="System.Web.Routing">
<add namespace="System.Web.WebPages">
</namespaces>

1) We send our request through HTTP to our server.
2) Then request goes through our MVC routing.
3) Our web request sends through Global.asax file where all routes are registered under this file, according to our MVC request then request is forwarded according to matching route.
ASP.Net MVC Page Life Cycle

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();
    WebApiConfig.Register(GlobalConfiguration.Configuration);
    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    BundleConfig.RegisterBundles(BundleTable.Bundles);
    AuthConfig.RegisterAuth();
    //ModelBinders.Binders.DefaultBinder = new Microsoft.Web.Mvc.DataAnnotations.DataAnnotationsModelBinder();
    AreaRegistration.RegisterAllAreas();
}
4) Route is filled in Route.Config file where our controller, view and parameter (optional) are given to complete our request.

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.MapRoute(
    name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    );
}
5) After filling the route through Route.config, now request is redirected to our controller.

  public ActionResult Index()
  {
   return View();
  }
6) At the end, Result is shown in a view of MVC controller attribute where all desired information is displayed over here.

@{ ViewBag.Title = "Home"; } 
<!DOCTYPE html> 
<html lang="en"> 
<head> <meta charset="utf-8" /> 
<title>@ViewBag.Title</title> 
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" /> 
<meta name="viewport" content="width=device-width" /> 
</head>
 <body> <div> Welcome to Technology Crowds </div> </body> 
</html>

Conclusion

In this article has shown how works MVC life cycle when we request through HTTP in our web browser. Requests, Routing, controller, view, MVC handler (Razor etc) are key components of MVC.

Suggested Reading

Monday

Fix SQL error: 26 - A network-related error occurred in SQL Server

Introduction

This article explains how to configure an instance of the SQL Server Database Engine to listen on a particular fixed port by utilizing the SQL Server Configuration Manager. The default example of the SQL Server Database Engine listens on TCP port 1433. Named instances of the Database Engine and SQL Server Compact are arranged for dynamic ports. This implies they select an accessible port when the SQL Server administration is begun. When you are interfacing with a named instance through a firewall, setup the Database Engine to listen on a particular port, so that the fitting port can be opened in the firewall. Here are given 5 different approaches to get resolution of 26 - A network-related error occurred in SQL Server. In my earlier, I have already explained how to find and delete duplicate values in SQL server.

Error Description:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)

Approach 1: We can run this query to view your TCP endpoints 


SELECT name, protocol_desc, type_desc, state_desc, is_admin_endpoint, port, is_dynamic_port, ip_address FROM sys.tcp_endpoints

tcp endpoints

Approach 2: Here you can check which SQL port is running on your machine.


USE MASTER
GO
xp_readerrorlog 0, 1, N'Server is listening on'
GO

Approach 3: Run below command to check applications listening on ports, try this command on command line:


netstat -ap TCP

Approach 4:


i) Open Immediate Window (Windows + R) on your machine.
ii) Next type %windir%\System32\cliconfg.exe and click on Enter button.
iii) Now a new window will open, left side will show disabled port and right side will show enabled port.
disable tcp ip protocols

iv) Now Select TCP/IP disabled protocols and click on Enable button to add in enabled protocols list.

tcp ip properties

v) Now you will enabled TCP/IP protocols and click on properties, then finally you will see SQL Server port i.e. 1433



sql port 1433

Approach 5: 

  • Start from open your SQL Server Configuration Manager
  • Next click  on "SQL Server Network Configuration" and click on "Protocols for Name".
  • Now right click on TCP/IP, click on properties and make sure it is enabled.
  • Presently Select "IP Addresses" Tab - and-Go to the last passage "IP All".
  • Now enter SQL server port TCP/IP 1433
  • Remove 0 (keep totally blank) from TCP Dynamic Ports property
  • Now restart your SQL Server (Right click on SQL server Management Studio and click restart button).

Conclusion

Here are given 5 different approaches to resolve issue 26 - A network-related error occurred in SQL Server. Hopefully, these approaches would work to all who are looking to resolve issue 26 - A network-related error occurred in SQL Server.

Relevant Reading

SQL Server Schema Corruption Error 211: A Technical Solution

The SQL Schema is a logical collection of SQL Objects including the tables, associated with columns, its relevant entries, or other elements. While creating the schema, a user will be able to access the database in more effective manner. However, a situation occurs in SQL server that different errors occurs while accessing it. One such error is SQL server error 211, which occurs when the server table is getting updated. In the following section, we will cover reasons for corruption in the server Schema and then possible solutions to overcome this error.

Problem Statement

Suppose a user tries to update some database tables on his server and meanwhile a schema corruption error message occurs on the system. This error can exist in any version of SQL Server such as Server 2005, 2008 etc.
“Msg: 211, Level 23, State 51, Line 1 Possible schema corruption.
Run DBCC CHECKCATALOG
Msg 0, Level 20, State 0, Line 0”

Reasons Behind SQL Server Error 211

Generally, schema corruption in database evolve very rarely in the SQL Server. When this error took place, a user have to check out the main cause of the error i.e., either via SQL error Log files or some other.
There are multiple reasons where schema gets corrupted and some of them are mentioned below:
  • Due to improper computer activities by server users
  • Sudden software failure leads to Schema corruption
  • Hardware failure is the major issue behind corruption

How to Fix Corruption Error 211 in SQL Server

There are several methods to resolve this server error. A user can choose any one approach to remove or delete the schema corruption which is present within the server. Following are the all possible solutions to fix the error:
  • One of the compatible solution for resolving this error is to restore the backup files of the database. In addition, go through following scenarios that will help you in restoring backup files:
    1. If a user has backup of transaction log, then take a backup of tail-log and restore the latest backup completely with entire transaction logs that are ending with tail-log backup. In such case, the result will become in 0 data loss.
    2. If a user does not have a backup of the transaction log then, develop a new database and import more data as possible or if a user is able to determine culprit table, then drop that table & recreate it.
  • The another approach is to repair entire MDF database file and then, you will have to deploy the database again.
  • The last manual trick is to execute DBCC CHECKCATALOG command on the server screen.
When you will run DBCC command the error will be displayed. Sometimes, much exceptions might occur while executing the Transact-SQL statement through SQL users with dedicated Schema. Make sure, a user will get the suitable suggestion from SQL server database by running DBCC CHECKCATALOG syntax. With the help of this command, users will get to know the location and reason behind the SQL server error 211. However, DBCC CHECKCATALOG signifies no error, but it is not possible at all time.

Foolproof Solution to Resolve SQL Server Database Corruption

The most appropriate solution for fixing SQL error code 211 is third party SQL recovery tool. It is safe and secure way to troubleshoot this error with help of following steps:
Step1: Launch SQL Recovery, Add MDF file and press Open button

Step 2: Analyze all your data of the server file and then click on Export button

Step 3: Now, select an option between two i.e., with the only Schema or with Schema & Data for exporting MDF file and click on save to start migration process

Finally, you will be able to get a healthy MDF file with help of this solution and hence, fix SQL server error 211.

Conclusion

Here we are ending with one of the server error, which create hurdle while accessing the SQL Server database. The best possible solutions are also discussed to overcome this possible Corruption Schema error. Well, it is recommended to first restore the backup file of server, if a user is having it. Else, you can go for other solution for resolving SQL server schema corruption error 211.

Product Review of Kernel for SQL Server

SQL Server is the well-developed Microsoft entity which provides flexible and correlational data management services to the organizations. Also referred sometimes as MS SQL and Microsoft SQL Server, The SQL Server is basically a set of relational database management service which extensively supports ANSI SQL, which is a standard server language. The SQL server also contains T-SQL, which is its own SQL implementation. Microsoft offers SQL server in different editions with different features and outcomes.
  • Enterprise Edition: Being the most expensive among SQL Servers, the Enterprise edition is meant for large organizations that deal in bulk volume of data every second.
  • Standard Edition: Perfectly designed to act as support for small and medium scale enterprises. It is prefect for medium level data volume.
  • Workgroup Edition: Perfect for startups and very small scale business groups. It is perfectly used for backend database for small webservers.
  • Express Edition: It is a free edition that is meant for distribution as it has limited number of features to be used. This edition is often referred to replace the Access database.
The availability of different editions of SQL Server is not so difficult, but the most common observation in every edition of SQL Server is issues with MDF and LDF files. The entire database of SQL server is saved in Master copy called MDF files. The MDF database files are the primary database file which entails schema and data. The other file format is LDF that maintains Log files. Due to some reasons the MDF files getcorrupt. To fix these MDF files it is important to take required action through some reliable source like Kernel for SQL Server.

Necessity of External Assistance

Kernel for SQL Server is an external agency designed to fix the MDF files that got corrupt due to technical complications. This SQL Server tool is perfect to fix the most notorious SQL-related issues. It includes:
  • MSDTC configuration issues.
  • Non-existent Disaster Recovery Plan.
  • Weak SQL login password.
  • TEMPDB pagelatch contention.
  • System Memory issues.
  • Usage of NOLOCK.
  • Non-scheduled Database Integrity checks.
From being a perfect tool to fix the SQL related issues to being a tool for maintaining the SQL Server, Kernel for SQL Server effectively manages every task assigned to it in a very simple manner. The entire credit goes to the inbuilt algorithm that drives the entire process.

An Intro to Kernel for SQL Server

Designed to fix the MDF file corruption with Auto SQL Version Detection Feature, Kernel for SQL Server haunts the SQL – related issues every time. The QFSCI algorithm takes care of the entire process with a great care for MDF file components. To experience the real functioning of Kernel for SQL Server the evaluation version can be downloaded that works exactly like the licensed version with a limitation of not restoring the recovered MDF files. The performance of this celebrity tool also depends upon the system configuration and supported versions. To eliminate any chance of incompatibility, the tool supports all versions of MS SQL Server, Windows OS and Windows Server. Moreover, prior downloading the evaluation version of the tool, it must be known to the user that the tool perfectly works in the system that comprises Pentium class processor with minimum 64 MB RAM and enough disk space to save results.

What is so special about Kernel for SQL Server?

Ardent features, which were once the dream of SQL Server users are now the reality and that too in the platform which can be easily managed. With user-friendly graphic interface no special training is required nor is any technical background needed. The only thing expected from the user is knowledge of the location of the MDB files and a rough estimate about the SQL repair tool’s working.
The specialty of Kernel for SQL Server lies in its features. These features play significant role in recovering the damaged MDB files:
  • Reveals the SQL Server version automatically.
  • Effective recovery of MDF files.
  • Essentially restores MDF file components like Tables, Index, keys and much more.
  • Dual Saving modes to save the MDF files differently.
  • Provides ‘Preview’ option to view the recovered items to ensure correctness.
  • Maintains data integrity throughout the process.
  • Independent of MDF file size limit.
  • Recovery of multiple MDF files in a single repair cycle.
To explore more about the tool it is suggested to download the trial version of the tool that works alike licensed version with a limitation of not saving the recovered MDF files.

Expanding Every Valuable Feature

  1. Witty Selection of MDF Files: Kernel for SQL Server makes quick selection of MDF files required to be recovered. To make this happen, the user-friendly GUI of the tool is available which can be independently tackled by any naïve user. To initiate it, user has to launch the SQL Recovery software followed by selecting the concerned MDF files. Once it is done the tool is ready to go.

Select Database to Recover

  1. Automatic Selection of SQL Server Version: To know the version of affected MDB files normally user applies conventional techniques but owing to the new technology that is used by external tool it has become very easy to find it out. To make this happen user has to select the concerned EDB file, upload it and tick the box that reads ‘Auto Detect Database Version’. On selection of this feature, your workload remains half and rest is performed by the third-party tool.

    Select SQL Database

  1. Stunning Recovery: The MDB files subjected to recovery are perfectly loaded by the user. With this action the manual support for the tool ends here. Now, following the remaining steps, everything is automated and just needs manual clicks to keep the process on going. On recovery of concerned MDF files, the user’s screen appears as like
Stunning Recovery

  1. Schematic Representation of Recovered Items: SQL Recovery Tool delivers B-tree structure of the recovered MDF file components. The schematic representation of the recovered items clearly makes the way for the user to select the specific file to ensure the correctness in the recovery process. User has to just select the object from the tree prior saving. When selection is made, the requisite content will be displayed on the right pane of the Window.
Schematic Representation of Recovered

  1. Save what is recovered: Post deciding that recovery is perfect, now is the time to get introduced to the stunning saving option. The saving mode gives a choice of saving the recovered files directly to SQL Server or simply to the Batch File.

Saving Mode

  1. Knowing the Performance Capacity: The Performance capacity of Kernel for SQL Server can be witnessed without spending a money or clicking the dialog box for online annual subscription. User has to simply download the evaluation version of the SQL Server recovery tool that has some limited potential to recover the damaged MDF files up to some extent. However, user cannot save any recovered files with it. To do so, the licensed version has to be purchased that facilitates limitless recovery irrespective of the SQL Server version.
  2. Speedy Delivery of License Key: Kernel for SQL Server is known for its outstanding performance. If user is satisfied with the tool’s performance in the evaluation version and is willing to purchase the licensed version of the same, then it can be done by using any of the different payment options like PayPal, Credit/Debit, E-Cheque and Pay Order. Once payment is received, the key of the licensed version is sent through the email to the user. In totality, it merely takes few minutes to procure the license key of the tool.
  3. Round-the-Clock Technical Support: The software is ardent in maintaining the client relationship. It is made possible by allowing technical support to the client whenever needed. Every ticket raised by the user is important for us and it is dealt with a great concern. After providing the required solution, it is conformed if user is facing any issues. The technical follow-up is kept to trace the history of the query that made the client concerned. To gain the online help related to SQL database recovery tool, user can simply log on to https://www.kerneldatarecovery.com/sql-recovery.html

Kernel for SQL Server Provides a Common Stage

Kernel for SQL Server is a center-stage to different versions of MS SQL and other required applications. The single stop solution for affected SQL files is responsible for fixing the SQL database irrespective of the version of its origin. To materialize the claimed capacity, the tool supports all versions of the required programs. This also eliminates all chances of incompatibility issues.
Supported Versions
  • MS SQL Server 2014/2012/2008 R2/2008/2005
  • Windows 10/8.1/8/7/Vista/XP/2000/98/NT/95
  • Windows Server 2012/2008 R2/2008/2003 R2/2003
Where Kernel for SQL Server fits the best?
The SQL Server Recovery tool graciously performs well in the system that comprises:
  • Pentium Processor
  • Minimum 64 MB RAM
  • 50 MB Space for Software Installation, and
  • Some space to save results.
The tool’s performance also depends upon the system configuration; therefore, prior downloading any version of the tool, it is recommended to check the system requirements.

Wednesday

How to find and delete duplicate values in sql server

Introduction

Today, I am writing about how to Find and delete duplicate values in SQL server and delete in our SQL Server database, sometimes data is inconsistent due to not proper relational integrity it results to duplicate rows in corresponding tables. Duplicate records of any database will lead to unstable application and it will not generate information according to end user expectation. I have clarified extremely known SQL Server error SQL Server Error 25 And 87.
SQL duplicate records

Monday

Software Review - Stellar Phoenix SQL Database Repair

While the database is in Suspect mode, no transactions are possible till it gets repaired. There can be a number of reasons due to which SQL database is marked as SUSPECT. These reasons include faulty hardware components, inappropriate shutdown, missing transaction log, malware attack, corruption in transaction log file, application crash and much more.

I came through the same situation where SQL Database turned to the SUSPECT mode. Analyzing the error log helped me to detect the actual reason behind the cause. This sometimes helps to bring the database to the online mode efficiently. To resolve this issue, initially, it requires changing the status of the database to EMERGENCY mode to gain read-only access as a DBA.

After doing this, I tried executing DBCC CHECKDB for executing logical and physical integrity checks. Further, repair_rebuild and repair_allow_data_loss were executed for SQL repair operation. However, during the initial attempt to gain access to the database tables, I realized that some content is missing.

Probability: Executing DBCC_CHECKDB with repair_allow_data_loss might have resulted in loss of data components and, sometime DECC CHECKDB with REPAIR_ALLOW_DATA_LOSS is not working.

Read here the complete article on this problem: http://www.stellarinfo.com/blog/dbcc-chekcdb-repair-allow-data-loss-not-working/

Since no recent backup is available, all deleted records need to be recovered. Then I decided to deploy Stellar Phoenix SQL Database Repair tool with the hope to get data recovered. The tool is known to integrate the following features:

     1. Repairs damaged MDF and NDF database files
     2. Recovers deleted records
     3. Recovers SQL tables, queries, rules, indexes, keys, defaults and triggers
     4. Recovers selective data from the selected database file
     5. Saves recovered files as HTML, MS SQL, CSV and XLS file formats
     6. Supports SQL Server 2016\ 2014\ 2012\ 2008 and lower versions

What does SQL Database Repair Tool Offer?

Since database encounters data loss after being recovered from the SUSPECT mode, the MS SQL database repair software was initiated for repairing the corrupt data. The performance of the tool is quite surprising as it recovered maximum contents from the inaccessible database files. Initially, the recovered contents get displayed within the tool panel.

Listed below is the complete functionality of the tool:


     1. Download, install and launch Stellar Phoenix SQL Database Repair. The tool will instruct to stop the SQL Server and copy the corrupted database to another location. This is quite practical because database connected to MS SQL Server cannot be modified as it is under the control of the Server.

Select Corrupt MDF file


     2. Click on Select Database button to upload the damaged database file: During MS SQL 2016 repair procedure, the tool provides the option to select the drive on system with the file type (i.e. MDF or NDF) and search database in that particular location. Alternatively, click on Find button if the location of the file is unknown.

     3. Select the checkbox that says “Include Deleted Records” to recover deleted data from database

     4. Click on Repair button to start the repairing procedure

     5. Select a particular component or folder from the left pane of the tool to preview the integrated items.Once the corrupt database file is selected, the tool enlists all the items saved into that particular file in the right panel of the tool
Preview of repaired data

     6. A message will be displayed that indicates “Selected MS SQL database repaired successfully”. Click on OK to save the repaired data
     7. The tool provides different options to save the repaired data that includes MS SQL, CSV, HTML and XLS
Save Repaired SQL Database

Note: The tool also provides the option to save repaired database file at a selected location on the machine. You can select destination path by clicking on the Browse button. By selecting the given checkbox, you can instruct the tool to automatically open the destination folder once the repaired file is saved.

     8. Then, click on the OK button
     9. Next, the tool offers to save the repaired data either in the New Database or Live Database

Note: You also need to provide Server credentials while saving repaired data to the SQL Server. Next, the tool will prompt you to enter the Server instance name, Authentication, and the name of Existing database. 

     10. The tool will display a message “File saved at the desired path.” Click on OK to complete the procedure
SQL Repair Versions and Purchase Information

SQL Database Repair tool offers two different versions that include: 

     - Trial edition
     - Licensed edition

The trial version of the software offers restricted access. With this version, you can test the functionality up to Step 6 mentioned in the above procedure. This version allows accessing the preview of the repaired data within the tool panel. However, the repaired data can be saved after purchasing the licensed version of the tool. 

To buy the licensed version of the tool, click on the Purchase icon available in the Help menu on the Menu Bar. Next, select the appropriate option for purchasing the software and select a payment mode. Once the payment is processed, the Serial Key will be sent to the registered email id. You can then activate the tool by using this Serial Key. 

Final Verdict
As per my experience, the functionality of Stellar Phoenix SQL Database Repair tool is accurate and efficient when tested on MS SQL 2016 database. During MS SQL 2016 repair process, the tool repaired entire data components that have become inaccessible after the database is brought online from Suspect mode. The integral contents and attributes of the tables, triggers, rules, indexes and other components remain intact, and the integrity of the database is not compromised. 

Saturday

CSRF: Prevent Cross-Site Request Forgery using AntiForgeryToken() in MVC

Introduction

At whatever point we chip away at our application we constrained to our undertaking extension and its business rationales to accomplish our task time conveyance. We couldn't concentrate such a great amount to our security reasons and later after sending of our venture is hacked through cross-site demand imitation. .Net Framework has introduced a new security feature to protect our MVC projects data using anti forgery token whenever we submit data through our MVC application data. Cross-site scripting (XSS) is most dangerous issue on web (internet application). I have already explained a MVC very known error Unexpected if keyword after @ character.
Prevent Cross-Site Request Forgery using AntiForgeryToken() in MVC