There are times when you might want to create an endpoint in ASP.NET WebAPI that can handle the HTML form data posted as x-www-form-urlencoded. One of the options is to use the model binding concept. In this case , the model should have the names of the keys that are passed in the HTTP […]
There are times when you might want to return the Http Status code from an action method of a ASP.NET Web Api Controller. One of the simplest way of doing this is using the CreateResponse method of the HttpRequestMessage as shown below. The sample below demonstrates how to return the status code 304 and 200 […]
In ASP.NET MVC , we can use the Server.MapPath or Request.MapPath to get the relative path of the server for a file. For example , The fileName would be the absolute path of the file. How to get the Relative Server Path in ASP.NET Web API ? You can use the HostingEnvironment.MapPath defined in System.Web.Hosting […]
There are times when you might want to serve binary files from your controller’s action method in ASP.NET MVC Web API. You can do this easily by setting the octet-stream content for the HttpResponseMessage as shown in the code snippet. How to return Binary File from a Action Method in ASP.NET Web API ?
There are times when you might want to add Web API project to one of your existing ASP.NET MVC project instead of creating a new one. How to Add Web API to existing ASP.NET MVC Project ? You can easily do that by installing it from NuGet. Simply open the Package Console Manager and run […]
There are times when you want to redirect to a specific area from different area. In this, one can use the RedirectToAction method to achieve it and pass the parameter area. How to Redirect between Areas in ASP.NET MVC?
It is easy to find out if the actual request came from Ajax or is it a normal request in ASP.NET MVC. In the controller, one can use the Request.IsAjaxRequest method to find this. How to find if the request is from Ajax in ASP.NET MVC? Below is a sample code snippet demonstrating how to […]
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 […]
Below is a source code snippet that demonstrates how to obtain the current domain in the controller of the ASP.NET MVC 4 Web Application. How to Retrieve the Current Domain 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 […]