Posts

Showing posts with the label ASP.NET

Donate

AngularJS $http service returns html instead of JSON string

Good day! I've been trying to consume an ASP.NET Web Method using AngularJS $http service and all I get from the response is the html page source instead of string data. After investigating and doing some searching, the workaround is to set the responseType to json and pass an empty data to the Web Method given that the Web Method has no parameter. var myapp = angular.module( 'myApp' , []); myapp.controller( 'ctrl' , function ($scope, $http) { $http({ url: "63MakeAjaxCallAndReturnJSONWebService.aspx/HelloWorld" , dataType: 'json' , method: "POST" , responseType: 'json' , data: {}, headers: { "Content-Type" : "application/json;" } }).then( function (response) { $scope.value = response.data.d; }); }); And also declare the Web Method as static. [WebMethod()] public static string HelloWorld() { return "Hello World!" ; }

ASP.NET 4.5 Has Not Been Registered on the Web Server (Visual Studio 2012)

This issue "ASP.NET 4.5 Has Not Been Registered on the Web Server" occurred when I opened an asp.net application built with Visual Studio 2012 recently when I installed Visual Studio 2015 in my laptop with a Windows 8 operating system. Given that this happens I assume that some settings may have been updated or corrupted by the recent version of VS. The solutions I have tried included registering asp.net through Visual Studio command tools with no effect. After searching through the web, I found a solution which is to download the hotfix for VS 2012 here Unexpected dialog box appears when you open projects in Visual Studio 2012 after you install the .NET Framework 4.5.3 . After downloading and installing the hotfix, the issue was resolved.

Adding ASP.NET 5 Templates To VS 2015

Image
Good day! One might notice that the ASP.NET 5 templates are not visible when creating a new Web Application Project in Visual Studio 2015 given that this is a fresh installation of the software. So to add the ASP.NET 5 Templates, download the ASP.NET 5 run-time tools Microsoft ASP.NET and Web Tools 2015 (RC) – Visual Studio 2015 and proceed with the setup. Restart your machine afterwards. That's it.. :-)

Sorting Of <li> Elements Using jQuery sort() Method Not Working (Refresh Page Only) In ASP.NET

Given the simple sorting code below which changes the order of <li> elements to ascending order and assuming that the text content of each li elements are numbers. $( function () { $( '#sortList' ).click( function (e) { // Select all the li items var numbersList = $( '#numbersList li' ); numbersList.sort( function (a, b) { return parseInt ($(a).text(), 10 ) > parseInt ($(a).text(), 10 ); }).appendTo(numbersList.parent()); }); }); The code should work only to find out that the page will only refresh after the button click. And then the re-arranging of the elements are discarded. The simple fix to this issue is to add the preventDefault() to prevent the button's default behavior that is to post back. $( function () { $( '#sortList' ).click( function (e) { e.preventDefault(); var numbersList = $( '#numbersList li' ); numbersList.sort( function (a, b) { var temp1 = parseInt($

Failed to load resource: the server responded with a status of 404 (WebResource.axd)

I downloaded a GridView custom control with cool features on search and filtering that was developed on Visual Studio 2010 and ASP.NET 4.0. After playing around with the control, I decided to migrate the files to Visual Studio 2012 ASP.NET 4.5. Upon running the ASP.NET Project, the resource to be embedded on the GridView control in which case a JavaScript file was not recognized/found. And thus, returned a 404 status. After doing some research, I came up with the solution below. Steps to fix the issue: 1. Set Build Action of the Resource/JavaScript file to Embedded Resource . In my project, the file to be embedded is EnhancedGridView.js 2. Add WebResourceAttribute to the GridView custom control to embedded a JavaScript file as Resource in an assembly. Make sure that the namespace of the file is correct. 1 2 3 4 5 [assembly: WebResource("GridViewFilter.EnhancedGridView.js", "text/javascript")] public partial class EnhancedGridView : GridView { //.....

Ajax Calls Not Working In Internet Explorer 8

After testing the external js files in IE 8, the calls to post data to a controller does not work. After googling, I found a fix that is to set true to jquery support cors. jQuery Code: 1 jQuery.support.cors = true ; CORS, INTERNET EXPLORER 8, AND XDOMAINREQUEST Cheers!

HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory (AngularJS)

Recently interested on AngularJS, I started reading Dan Wahlin's AngularJS material and downloaded the samples in Visual Studio 2012. Upon running the code, I encountered an error which is the title of this post. After days of testing, I noticed that the url doesn't change on runtime since each examples are treated as partial views loaded into a main view. This lead me to the right direction which is a solution from Microsoft on enabling defaultDocument in web.config. Web.config: <system.webServer> <defaultDocument enabled= "true" > <files> <add value= "home.html" /> </files> </defaultDocument> </system.webServer> Where home.html is the main html document which the partial views are loaded.

Register Composite Controls In ASP.NET Web.Config

After working on a simple composite control in asp.net, the last task was to register the control so that the asp.net page can consume it. I got it working by registering the control in web.config. Source: Register Composite Controls in web.config

.NET 4.5 Framework Features

Image
Here's an image i got from  http://muralitharan.info  blog. Thanks to the guy who uploaded this image... :) Greg

How To Set Connection String In Properties.Settings Of ASP.NET Class Library Project

Image
Usually, we set an asp.net connection string directly in the app.config. However, we can also do it Properties.Settings. As soon as we saved the name and value, it will reflect in the app.config. Here's a sample image as reference: Cheers!

Content Types Or MIME Types List In ASP.NET MVC

I have searched for content types which is suitable for ASP.NET or ASP.NET MVC applications using the HttpResponse class ContentType property. Here's the website with the MIME list: Mime Type List Here's a sample asp.net/mvc snippet. HttpResponseBase response = context.HttpContext.Response; response.ContentType = "application/pdf" ; Greg

The Official Microsoft ASP.NET Site

http://www.asp.net/ (Main ASP.NET Website)

Donate