Category: ASP.NET

Difference between Html.EditorFor and Html.TextboxFor in ASP.NET MVC?

If you are working on Web Application development using ASP.NET MVC, you would come across the Html.EditorFor and Html.TextboxFor in the Razor View. What is the Difference between Html.EditorFor and Html.TextboxFor in ASP.NET MVC? The Html.TextboxFor creates a textbox with the input type of text. It will always render the input textbox. The EditorFor is a kind of smart helper method. This will render the…

Layout = null vs. ignoring Layout Property in ASP.NET MVC

What does Layout=null and ignoring the Layout property within the View means ? This is pretty simple , Layout=null , the view does not use any layout and the layout of the page will be the one used within the view. Ignoring the Layout property is a different story . Sometimes , ViewStart file can be used with the Views folder to define the layout…

What is the Difference between Repository and Service Layer in ASP.NET MVC?

Repository pattern, Unit of Work and Service Layer is one of the most commonly used word or technique especially when you are working on the ASP.NET MVC project. What is the Difference between Repository and Service Layer in ASP.NET MVC? These are the common Design pattern terms used in the ASP.NET MVC project. The Repository is a layer that provides additional abstraction on the data…

How to read a key from the Web.Config file in ASP.NET app using C# ?

If you want to read the values based on the key from the web.config file in your ASP.NET application using C# , you can use the  WebConfigurationManager to do it. How to read a key from the Web.Config file in ASP.NET app using C# ? Assume that the configuration file contains the below values If you want to read the value of the key (“UserName”)…

HttpUnauthorizedResult in ASP.NET MVC

The ActionResult can take different values like View , PartialView, String etc, Another value that it can take is HttpUnauthorizedResult . The HttpUnauthorizedResult when returned from a View will force the user to login in. HttpUnauthorizedResult in ASP.NET MVC

IController in ASP.NET MVC

Every Controller in ASP.NET MVC is extended from the Controller abstract class which in turn implements the IController interface. The IController interface is defined in the System.Web.Mvc namespace of the .NET Framework. The IController interface contains the method Execute which is called when the user enter the URL which involves the implemented controller class. The controller classes that you create can implement IController but you…

Installing ASP.NET MVC and Prerequisites

To develop ASP.NET MVC Applications , you need Visual Studio to be installed . The Visual Studio contains all the necessary stuffs to get started . You can download Visual Studio 2012 or Visual Studio 2010 and install it from Microsoft Download Center. Download Visual Web Developer 2012 from Visual Studio website The Visual Studio 2012 has the necessary and latest ASP.NET MVC templates to…

How to Create a View in ASP.NET MVC ?

Every Web Applications needs to have the UI through which the user can interact with . You can easily create a View in ASP.NET MVC by following the below steps. How to Create a View in ASP.NET MVC ? 1. Right Click on the Action Method in the Controller and click “Add View” in the context menu. 2. In the Add View Dialog , give…

How to Add Web API to existing ASP.NET Web Forms Project ?

In one of the previous posts , we saw how to add the WebAPI to the existing ASP.NET MVC project. Well , the process of adding the ASP.NET Web API to the existing ASP.NET Web Forms project is still the same. You can easily do that by installing it from NuGet. Open the Package Console Manager in Visual Studio 2015 and run the following command….

How to retrieve the IP Address in ASP.NET MVC Web Application ?

If you want to retrieve the client’s IP Address in ASP.NET MVC , there are couple of ways that you can achieve this. How to retrieve the IP Address in ASP.NET MVC Web Application ? 1. Use the Request.ServerVariables[“REMOTE_ADDR”] which will retrieve the IP address in ASP.NET 2. You could also use the Request.UserHostAddress to achieve the same. Below is a sample controller sourecode demonstrating…

iText Library for Creating PDF documents in C# and Java

iText is a PDF Library or API (Application Programming Interface ) that allows the developers to generate PDF documents based on the data from database or XML file. iText is available in Java as well as .NET (C#) and uses LDF’s many interactive features. iText library allows the developers to add bookmarks , page numbers and watermarks. Know more about iText Library for Creating PDF…

CS1502: The best overloaded method match for System.Web.WebPages.WebPageExecutingBase.WriteSystem.Web.WebPages.HelperResult)’ has some invalid arguments Error in ASP.NET MVC

If you are getting the below error message in ASP.NET MVC Web Application, you can resolve it by looking at the methods that renders the partial view in the screen. “Server Error in ‘/’ Application. ——————————————————————————– Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code…

RegisterArea in ASP.NET MVC

In the previous article, we provided you an overview of the areas in ASP.NET MVC. When a new area is created in ASP.NET MVC, a file with the area name suffixed by AreaRegistration will be created. In the example as described in the previous article, the AbundantcodePayrollAreaRegistration.cs contains the following This class contains the RegisterArea method which is used to register the route with the…

Could not load file or assembly … An attempt was made to load a program with an incorrect format (System.BadImageFormatException)

There are times when you might get the following error when running the application from Visual Studio or opening your application page in the browser. Could not load file or assembly … An attempt was made to load a program with an incorrect format (System.BadImageFormatException) I received this error recently when trying to deploy the application in the IIS and accessing the page from the…

Browser Plugins (Adobe Flash) Detection Toolkits

This article will cover some of the browser detection plugins. There are scenarios where the web developer might want to find out if the Plugin is installed in the browser. The Web developers can use browser plugin detection toolkits/plugins to do it. Browser Plugins (Adobe Flash) Detection Toolkits Jqplugin This plugin extends the jQuery browser object and detect plugins in the browser. Some of the…