Posts

Donate

HTTP Error 500.23 - Internal Server Error. An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode. (ASP.NET MVC HttpHandler)

Good day! I was trying to apply integrate an Image HttpHandler that discourages leeching from one of my Web Forms project to ASP.NET MVC. This hack is found on ASP.NET 2.0 MVP Hacks site. Upon running the ASP.NET MVC project, an issue was thrown to the browser specifically "HTTP Error 500.23 - Internal Server Error. An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode." Upon investigating, I found out that handlers in WebForms are declared in <httpHandlers> under <system.web>. <system.web> <httpHandlers> <add verb= "*" path= "*.jpg" type= "Events.Web.Extensions.NoLeechImageHandler" /> <add verb= "*" path= "*.jpeg" type= "Events.Web.Extensions.NoLeechImageHandler" /> <add verb= "*" path= "*.gif" type= "Events.Web.Extensions.NoLeechImageHandler" /> <add verb= "*" path=

Hide ASP.NET Web Forms GridView BoundField Column With Value Accessible Through JavaScript

To hide a BoundField column but make it's value still accessible through JavaScript just set column's ItemStyle-CssClass and HeaderStyle-CssClass properties using CSS class with value display:none . CSS .hiddenColumn { display : none ; } ASPX <asp:BoundField DataField= "GroupCode" HeaderText= "Group Code" ItemStyle-CssClass= "hiddenColumn" HeaderStyle-CssClass= "hiddenColumn" />

Display Images Using Generic Handler In ASP.NET MVC

Image
There are several options on how to show images in ASP.NET MVC. One of them is using a generic handler. This method was applied since the early days of ASP.NET Webforms and still can be used with recent frameworks. The class below will render the images on the page by calling the ProcessRequest method which will then get the image from datasources such as database and file system and return it as a Bitmap object. public class ImageHandler : IHttpHandler { private OnlineShoppingDBEntities shoppingContext; public ImageHandler () { shoppingContext = new OnlineShoppingDBEntities(); } public void ProcessRequest (HttpContext context) { if (context.Request.QueryString[ "ProductID" ] != null ) { Product product = shoppingContext.Products.Find(Convert.ToInt32(context.Request.QueryString[ "ProductID" ])); if (product != null ) { Byte[] bytes = product.Image; int height = 0 ; int width = 0 ; height = 100 ; width = 10

Add Glyphicon To Ajax.ActionLink() In ASP.NET MVC

Image
Good evening! Adding a Bootstrap glyphicon to Ajax.ActionLink() helper is similar with Html.ActionLink() except that when the linkText parameter of the helper is empty, it will cause an Ajax issue and an Internal Server Error will be thrown from the browser. If you're going to integrate glyphicons on Ajax.ActionLink() helper and exclude the linkText property, supply that parameter with space instead of empty string so as not to cause jQuery or Ajax issues. @Ajax.ActionLink( " " , "DeleteComment" , "Home" , new { id = comment.CommentID }, new AjaxOptions { OnBegin = "return confirm('Are you sure you want to delete this comment?');" , InsertionMode = InsertionMode.Replace, UpdateTargetId = "event-details-" + Model.Id, HttpMethod = "GET" , }, new { @class = "commentDelete glyphicon glyphicon-trash" }); linkText i

Invalid nested tag div found, expected closing tag input

Hello all, I've been experimenting on how to print html document using the said 3rd party software called iTextSharp . iTextSharp is a popular tool and has several examples on the internet regarding integration to the project and occurring issues. One of the issue I encountered is Invalid nested div tag and is expecting a closing tag input . As I trace back my html source, the tags are well-formed except that they are self closing tags such as <input>, <hr>, <img>, <br> or the like. These tags when passed to an action method as string are not properly closed and thus an issue is thrown by iTextSharp's XMLWorkerHelper's ParseXHtml() method. <img src= "~/Images/success.png" /> <input type= "hidden" name= "OrderStatusHTML" /> <input type= "submit" id= "btnSubmit" value= "Export to PDF" class= "btn btn-success" /> The solution I came up with is to fi

Add Glyphicon To Html.ActionLink() In ASP.NET MVC

Image
Hello, Here's how to integrate glyphicon to Html.ActionLink() helper in ASP.NET MVC. The code below will display the glyphicon shopping cart right after the text Checkout of the anchor element. @Html.ActionLink( "Checkout" , "Index" , "Home" , null , new { @class = "btn btn-info glyphicon glyphicon-shopping-cart" }) In order to add the glyphicon before the text of the anchor element, use @Url.Action() instead. <a href= "@Url.Action(" Index ", " Checkout ")" class= "btn btn-info" > <span class= "glyphicon glyphicon-shopping-cart" ></span>Checkout </a> Output:

Formatting Numbers Using toLocaleString() In JavaScript

I've been using a JavaScript 3rd party library to format numbers with comma and decimal place(s). The JavaScript library called NumberFormatter was introduced to me by my developer with exceptional skills in front-end programming. Due to simplicity sake, I'm exploring options if this can be achieved using an existing JavaScript function instead of using the existing 3rd party app. After doing some research, I found an answer here: How to use toLocaleString() and tofixed(2) in javascript which is to use toLocaleString() by setting the options minimumFractionDigits and maximumFractionDigits to 2. Number .prototype.toLocaleFixed = function (n) { return this .toLocaleString( undefined , { minimumFractionDigits : n, maximumFractionDigits : n }); }; Sample usage: var result = parseFloat (amount).toLocaleFixed( 2 )

Task Management System With Entity Framework And ASP.NET MVC

Image
Hello, Here's a simple Task Management System with Entity Framework 6 taken from Udemy's Asp.Net MVC With Entity Framework From Scratch video tutorial. The output of the project should be in ASP.NET Webform but I chose to upload a sample in ASP.NET MVC which is intended for ASP.NET MVC developers. The entire source code can be downloaded here: Task Management System MVC . The project includes the stored procedure necessary to display the data through the grid. As for the database table, it is included in the tutorial series through a PDF file. Output Cheers!

Ajax.ActionLink() Not Redirecting To ActionResult With Ajax Attribute

Given that I have this code in my .cshtml page using Ajax.ActionLink() that calls a controller method using Ajax request: @Ajax.ActionLink( "Select" , "TaskListing" , new { id = item.TaskID }, new AjaxOptions (){ HttpMethod = "GET" , UpdateTargetId = "taskListing" , InsertionMode = InsertionMode.Replace }) And the controller method called by the Ajax ActionLink is decorated with Ajax attribute. [HttpGet] [AjaxOnly(true)] [ActionName("TaskListing")] public ActionResult TaskListing_Ajax ( int id = - 1 ) { var projects = projRep.GetAllProjects(); var model = new TaskAndTaskViewModel(); model.Task = te.Tasks.FirstOrDefault(t => t.TaskID == id); model.SelectList = from p in projRep.GetAllProjects() select new SelectListItem { Selected = (p.ProjectID == Convert.ToInt32(model.Task.ProjectID)), Text = p.ProjectName.ToString(), Value = p.ProjectID.ToString()

Read .NET Configuration Files Using NameValueSectionHandler And AppSettingsSection Types In C#

Hello all, I've read from a tutorial NameValueCollection and .NET Configuration Files which targets .NET 1.0/1.1 on how to read config files using type NameValueSectionHandler. I intend to explore more on applying this concept to recent versions of .NET frameworks. Upon doing some diggings, I came up with two options. First is using NameValueSectionHandler type and the other one is AppSettingsSections. To begin with, I have this App.config file with XML elements scriptsfiles and docfiles all registered in configSections. <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name= "scriptfiles" type= "System.Configuration.NameValueSectionHandler" /> <section name= "docfiles" type= "System.Configuration.AppSettingsSection" /> </configSections> <scriptfiles> <add key= "C:\batchfiles\2017" value= "*.bat" />

Donate