ASP.NET MVC - HttpException visible in View Source in browser - asp.net

I developed an asp.net mvc application. In one of my forms, I'm getting a following
exception:
A public action method 'UpdateBasket' could not be found on controller 'App.Controllers.WebShopController'
But the funny thing is, that form submit works (even in debug mode) and finds an
ActionMethod UpdateBasket and returns View.
The problem is that because of that html generated error
w3c validators and google crawlers can't access the site (I think so, correct me if I'm wrong).
Has anybody got any idea why this error occurs? Thank you.

Perhaps you're using Google Chrome to view the page source and you're encountering its tendency to reissue a "get" request for a post-only URL that your browser just "post"-ed to?
This is the best description I've found.

Related

Sys.WebForms.PageRequestManagerParserErrorException: When using MVC, MvcReportViewer and Asp.Net aspx page

I have already a web application in mvc 4. My SSRS reports are available in different server. I am trying to show the report in mvc application. Please find the steps which i followed to show the report.
Created a aspx page which contains the report viewer
Added the controller in mvc
Calling a view page from the controller
From the view page i am importing the aspx page using html.partial("aspxpagenamewithoutaspxextension")
When i run the action, I am able to see the report with the parmaters.
After i chosen the parameters, when i clicked on the submit button i am getting the following javascript error.
Sys.WebForms.PageRequestManagerParserErrorException: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.
Please help me to fix this issue. In case if you need more information this i will give.
I was receiving this error and once change we made on the RDLC was to set the property ReportViewer.AsyncRendering=false and that solved the issue for us. By default the ReportViewer.AsyncRendering is set to true which I believe has dependencies on AJAX controls to do what it needs to do... for that reason we set the rendering to false.
You can probably try that and let me know.

I am getting /'undefined' redirection from my MVC 3 Razor Website

I have MVC 3 website. When checked Google Analytics I saw 'undefined' error and I don't know why I am getting that error.
When I visit that page below I am not getting but some how someone getting that redirection to undefined.
How can I define why I am getting that error or is it something with MVC 3?
ORIGINAL WEB PAGE
http://www.emlakrex.com/Sonuc/detay/Merkez,Bursa,Kiralik,Arsa,Arazi,Ilanlari,2000-TL/PrptyID-273163
REDIRECTED WEB PAGE
http://www.emlakrex.com/'undefined'
undefined often comes from javascript. I can only assume that your re-direct is carried out by javascript, or, you have some java script function that attempts to use an undefined variable. Please provide some code samples of where you think this is failing.

"Sys is undefined" error because WebResource.axd is returning the wrong content

I'm getting the dreaded "Microsoft JScript runtime error: 'Sys' is undefined" error while trying to develop a site in ASP.NET on .NET framework 4.0. This was working fine until I tried programmatically adding items to a menu, and this started happening. While debugging, I pointed Fiddler at my app and found that the request for the WebResource.axd is returning successfully (code == 200), but the response text is the whole html page and NOT the javascript that it is supposed to be returning, and this is why Sys is undefined.
What's going on here? Any help much appreciated. Thanks.
Solved, thanks to this. I'm using ASP.NET Routing, and I was routing root level requests like http://www.mysite.com/{PageId}, and this matching pattern is so general that it was also matching the request for /WebResource.axd, and that's why the page request for the axd file was being routed to an aspx page instead of the usual handler. Not what I would have expected, but I can see the logic.
The fix is to tell the routing system to ignore this particular kind of request:
RouteTable.Routes.Ignore("{resource}.axd/{*pathInfo}")

Problem: System.Configuration.ConfigurationManager throwing exception

I am having this strange case, at first time when the page loades, everything goes fine. But as soon as I click on any link which makes any ajax request, after that, I get this error while trying to read the configuration.
"System.Configuration.ConfigurationManager.ConnectionStrings' threw an exception of type 'System.Web.HttpException"
I am using asp.net mvc 1.0
Please help.
Thanks in advance.
The problem was coming because of an ajax request which was having one of the route data parameter with space eg. www.domain.com/account/index/%20routedata. In this case, the firebug was showing 404 not found error while as debugging was enabled on the machine, it was throwing the above mentioned exception.
You need to use WebConfigurationManager and not ConfigurationManager in a web project.

Design Pattern for error handling in ASP.NET 3.5 site

I am relatively new to ASP.NET programming, and web programming in general. We have a site we recently ported from .NET 1.1 to 3.5. Currently we have two methods of error handling: either catching the error during data load on a page and displaying the formatted error in a label on the page, or redirecting to a generic error page. Both of these are somewhat annoying, as right now I'm trying to redesign how our errors are displayed.
We are soon moving to Master pages, and I'm wondering if there is a way to "build in" an error handling control. What I mean by this is using a ASP.NET user control I've designed that simply gets passed the error string returned from the server. If an error occurs, the page would not display the content, and instead display the error control. This provides us with the ability to retain the current banner/navigation during an error (which we don't get with the generic error page), as well as keeping me from having to add the control to every aspx page we have (which I have to do with using the label-per-page system). Does something like this make sense? Ultimately I just want to have the error control added to a single page, and all other pages have access to it directly. Is this something Master pages help with?
Thanks!
User the application_error event in the global.asax to catch all your unhandled errors - you can log them here. You shouldn't be outputting error messages to the client like this.
Use the CustomErrors section in the web.config to define a custom error page for your users to get.
You could also look at using something like ELMAH for easy loggin.

Resources