Skip to main content

Posts

Showing posts from April, 2024

ASP.NET MVC with Large JSONResult

Error:-  Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. Solution:- In this help topic, we will use a custom JsonResult Class for ASP.Net MVC to avoid MaxJsonLength Exceeded Exception. The class is called LargeJsonResult. Below is the implementation of the LargeJSONResult class: using System; using System.Web.Script.Serialization; namespace System.Web.Mvc { public class LargeJsonResult : JsonResult { const string JsonRequest_GetNotAllowed = " This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet." ; public LargeJsonResult() { MaxJsonLength = 1024000; RecursionLimit = 100; } public int MaxJsonLength { get; set; } public int RecursionLimit { get;...

How to Scroll to an Element with Javascript

  Overview Scrolling to a specific element or part of a webpage is mainly done to keep a user intact with the webpage for a longer period. A scroll is a function that can be used also to scroll to the beginning of a webpage from the bottom of the webpage instantly. Instant scrolling functionality is done or implemented using JavaScript. Scrolling to a particular section of a webpage adds a single-click functionality without much intervention from the user. There are different JavaScript scroll to element methods that are used to implement the functionality of scrolling to a particular element. These methods include: JavaScript  scrollIntoView  method. JavaScript  scroll  method. JavsScript  scrollTo  method. In this article, we will understand them thoroughly. Introduction Before learning about the JavaScript scroll to element, Let's learn a bit about JavaScript. JavaScript  is an object-oriented programming language used on web pages. JavaScript ...

Custom Web Browser in MVC

  we need to add webbrowser with threading other wise we will get  ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.  error this is the way we can make webbrowser work in asp.net webpages using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Threading; using System.Windows.Forms; /// <summary> /// Summary description for CustomBrowser /// </summary> public class CustomBrowser { public CustomBrowser () { // // TODO: Add constructor logic here // } protected string _url; string html = "" ; public string GetWebpage ( string url ) { _url = url; // WebBrowser is an ActiveX control that must be run in a // single-threaded apartment so create a thread to create the // control and generate the thumbnail Th...