Skip to content

Codepolice

  • ⤫

StackoverflowException with ASP.NET MVC

Posted by Judy Alvarez Posted on February 25, 2022March 1, 2022
0

I got this strange Stackoverflow exception today in my MVC project. I have made some modifications to my data model and all of a sudden I got a stack overflow exception when I was submitting data via a form.

I started googling about it and found this thread on the asp.net message board. It turns out that the Default model binder was causing this. The model binder is basically what makes ASP.NET MVC able to automatically bind form post values to your object. You probably know it to some degree if you reading this.

Anyway, to solve the problem you should declare what fields you want to include in the binding by adding an attribute like this. This way the model binder won’t have to deal with the properties that you do not handle in some way.

public ActionResult Ask([Bind(Prefix="question",Include="Text,Title")]Question question)

According to the post in the forums, this is a bug that will be fixed in the next release of the MVC framework. Now back to work!

Read more about both model binders and the bind attribute at Scott Guthries blog post about the beta.

Categories: JavascriptTagged: asp net angular, asp net api, asp net application, asp net core 3.1, asp net core api, asp net core blazor, asp net core dependency injection, asp net core docker, asp net core environment variables, asp net core vs asp net, asp net core web application, asp net development company, asp net frameworks, asp net login, asp net mvc 4, asp net signalr, asp net tutorial c#, asp net tutorial for beginners, asp net versions, asp net web hosting, asp net webform, authentication asp net, data binding in asp net, download asp net, microservices asp net core, middleware in asp net core, radio button in asp net, required field validator in asp net, smarter asp net, windows authentication in asp net

Post navigation

Previous Previous post: Generate expiring urls for Amazon S3 via a WordPress Plugin
Next Next post: Remote Desktop Connection (RDP) becomes extremely slow after installing “Intel Smart Connect Technology” update

Related Posts

  • Ways to remove event listeners

    #​624 — February 3, 2023 Read on the Web JavaScript Weekly You’ve Got Options for Removing Event Listeners — Unnecessary event listeners can cause all sorts of odd problems so it’s good to clean them up when you don’t need them anymore. How? There are several approaches and Alex looks at their pros and cons. (once

    Posted by Posted on February 3, 2023
    0
  • SQL in your JavaScript

    #​472 — February 2, 2023 Read on the Web AlaSQL.js 3.0: Isomorphic JavaScript SQL Database — A SQL database you can use in Node.js and the browser. The interesting bit, for me, is how it opens up the idea of using SQL to query JavaScript objects – as in this example. “The library adds the

    Posted by Posted on February 2, 2023
    0
  • Astro 2.0 and TypeScript 5.0 beta

    #​623 — January 27, 2023 Read on the Web JavaScript Weekly Astro 2.0: The Next-Gen ‘Islands’-Oriented Web Framework — 2.0 includes hybrid rendering (mixing of SSR and SSG outputs), type safety for Markdown & MDX, and an upgrade to Vite 4.0. Astro is worth exploring when performance is key as it works with popular frameworks

    Posted by Posted on January 27, 2023
    0
  • Automating the desktop with Node

    #​471 — January 26, 2023 Read on the Web Nut.js 3.0: Use Node for Desktop Automation — Take control of your desktop environment (Windows, macOS or Linux) from code with control over keyboard and pointer, plus you get some image matching possibilities too. Open source but with optional sponsor-only extension packages. GitHub repo and what’s new

    Posted by Posted on January 26, 2023
    0
  • Why document.write() is bad

    #​622 — January 20, 2023 Read on the Web JavaScript Weekly Why Not document.write()? — Many moons ago, document.write was a mainstay of client-side JavaScript code, but it’s long been considered a bad practice – why? Harry digs in, noting that it “guarantees both a blocking fetch and a blocking execution, which holds up the

    Posted by Posted on January 20, 2023
    0
  • We’re going on a memory leak hunt

    #​470 — January 19, 2023 Read on the Web Fixing a Memory Leak in a Production Node App — Kent encountered a variety of weird memory and CPU usage spikes in his Node-powered app and decided to figure out what was going on. This post walks through his complete journey, with plenty of side problems

    Posted by Posted on January 19, 2023
    0
Judy Alvarez

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Codepolice

  • Github
  • Atlassian
  • Flatlogic
  • Xero
  • Jetbrains
  • Figma
  • Ways to remove event listeners
  • SQL in your JavaScript
  • Astro 2.0 and TypeScript 5.0 beta
  • Automating the desktop with Node
  • Why document.write() is bad
https://flatlogic.com/generator
COPYRIGHT © 2023 - Codepolice