Report Model State And Application Errors To Client?

Mar 2, 2011

I'm wondering what the best practice is in reporting back to the browser about application or model state errors that would be displayed to the user. Can you throw an exception and handle it in the error handler of the jquery post? For example, consider this method:

[HandlerErrorWithAjaxFilter, HttpPost]
public ActionResult RetrievePassword(string email)
{
User user = _userRepository.GetByEmail(email);
if (user == null)
throw new ClientException("The email you entered does not exist in our system. Please enter the email address you used to sign up.");
string randomString = SecurityHelper.GenerateRandomString();
user.Password = SecurityHelper.GetMD5Bytes(randomString);
_userRepository.Save();
EmailHelper.SendPasswordByEmail(randomString);
if (Request.IsAjaxRequest())
return Json(new JsonAuth { Success = true, Message = "Your password was reset successfully. We've emailed you your new password.", ReturnUrl = "/Home/" });
else
return View();
}

Is it correct to throw an exception in this case when the user is null? Or should I instead do this and handle it in the success handler of the jquery post: return Json(new JsonAuth { Success = false, Message = "The email you entered does not exist in our system. Please enter the email address you used to sign up.", ReturnUrl = "/Home/" });

View 1 Replies


Similar Messages:

Application Hosted On IIS7 That Is Ignoring Custom Errors And Falls Back To IIS Errors?

Jul 2, 2010

I have a C# web forms ASP.NET 4.0 web application that uses Routing for URLs for some reason custom errors defined in the system.web section of my web.config is entirely ignored and it will fall back the IIS errors.

This gets entirely ignored

[code]....

This would be a minor inconvenience except that by the fact it falls back to IIS native instead of my application it completely circumvents Elmah logging my 404 exceptions correctly.

View 3 Replies

SQL Reporting :: Create A Click Through Report Using Report Model?

Nov 29, 2010

how to create a Click through report using Report Model.

View 1 Replies

Crystal Reports :: Persistent CR Errors "Failed To Open Report", "The Maximum Report Processing

Nov 6, 2010

Our heavily-used VS2005 application uses CR (10.2) for an MSWord-formatted stream to a webservice, and for printing from a CRViewer. We continue to get "Failed to open report" or "The maximum report processing jobs limit configured by your system administrator has been reached". Once the error starts, the only remedy is recycling the application pool, disconnecting current users.

I have used the proper ReportDocument Close() and Dispose(), and even GC.Collect(), in Page_Unload. I upped the Print Job Limit from 75 to 300. After recycling I delete temp files.

1) Is there any way to monitor the use of the CR resources, to see when they increase and get close to the limit?

2) Is there any way to free them without having to disconnect users?

I suspect users are simply closing their browser after printing from an open CR Viewer. It would still go through Page_Unload, right? So maybe I would benefit from closing and disposing the CR Viewer in Page_Unload as well as the click that returns them to the application.

I had assumed that to permit users to page through the report, the CR Viewer had to have ViewState enabled, and remain open through Page_Unload.

View 2 Replies

MVC :: Model State Doesn't Contain Model Values

Aug 2, 2010

when I use Html.HiddenFor( model => model.OwnerId ) to create a hidden field, the value assigned to that field is zero. When I use <input type="hidden" value="<%: Model.OwnerId %>" /> to add the hidden field to the form, the value is assigned correctly.

Why would Html.HiddenFor( model => model.OwnerId ) not get the correct value from the Model object? Am I supposed to load model state somehow separate from returning the model object from the action method? Here is the view:

[Code]....

The Create action method is relatively straight forward.

public ActionResult Create( ... )
{
ViewStockItem item = new ViewStockItem();
item.ActionCode = ActionCode.Add;
if (item.OwnerId == 0)
item.OwnerId = 7;
BookOwner owner = db.BookOwners.Single(c => c.OwnerId == item.OwnerId);
item.OwnerName = owner.OwnerName;
return View(item);
}

View 4 Replies

MVC :: ValidationSummary / Only Displays Model-level Errors?

May 18, 2010

If I pass in true to the ValidationSummary() helper so that it only displays model-level errors, how can I get the summary to display custom errors I add to ModelState?For instance, here is what I am after. I want my data annotation errors to display next to the textbox's using the ValidationMessage helper, but in my business layer I may throw an exception that I want to display in the validation summary.

View 1 Replies

ADO.NET :: Open Project And Model.Designer.cs Has So Many Errors

Mar 7, 2011

The first time I created my model, I thought a manual fix would keep it okay. But everytime I open my project, the model is updated and the Designer.cs is formatted weird. The following picture shows the main problem: I'm just not sure how to permanently fix it other than going through and deleting the "System.Data." and "System.whatever" paths when they are referenced. That is the only way the build/publish succeeds, and it's very time consuming to complete each time.

View 3 Replies

MVC :: Sending Errors Back To View From Model?

Mar 26, 2010

Suppose i have an insert function in my model like so:

//INSERT
public int? Insert(DataLayer.PersonRow row)
{

[code]...

View 2 Replies

How To Return Errors To View From Controller Not Tied To A Specific Model Property

Aug 26, 2010

Curious what the best practice is for returning errors to a view from a controller where the error isn't really a validation error, but more like "user not found" or "service timeout" type of errors. (in ASP.NET MVC2 framework)

I've been adding them to the ModelState's model errors, but that doesn't seem appropriate. (although easy to implement and maintain)

Example - A user tries to log in, and their credentials do not match a known user.

View 1 Replies

MVC :: To Report Modelstate Errors Via Ajax Request?

Mar 8, 2010

How to send the modelstate errors or any other exception to the view via ajax?

View 3 Replies

SQL Reporting :: SSRS Report Displays In FireFox But Errors In IE?

Mar 30, 2010

I have an SSRS report that displays fine in FireFox.

But, when view in IE7 I get Execution Not found.

Does anyone know why it doesn't work in EI, but does in FF?

View 9 Replies

ASP.NET - Use Tracing To Capture Errors And Send Report Back To ADMIN?

Jul 9, 2010

I wanted to use tracing to capture errors and programmatically send reports via email and text message...that if the ADMIN is eating out at a restaurant on a saturday nite he can see the text message/email to notify and capture..any way to do this??

View 1 Replies

Mvc Client Side Validation - List All Generated Errors In The Same Div?

Sep 8, 2010

How do I list all generated errors in the same div?

Something like this:

<div id="errors">
<ul>
<li>Email is invalid</li>
<li>Firstname is required</li>
</ul>
</div>

View 1 Replies

Web Forms :: Hook Up Error Page, Store Report Of Errors In Log File Or Send E-mail

Dec 17, 2010

I would like to hook up custom error page to my ASP.NET web site.What I would like to do is that. When any error occured transfer the visitor to a custom error page informing about the error,

and at the same time log into a file or send an e-mail to my email account reporting the error.Then an other thing how can I generate error for testing the my Eventhandler method?

View 4 Replies

Web Forms :: Combining JQuery Client And Server Side Errors In Same Summary

Feb 25, 2010

I am using JQuery for all of my client side validation and Asp.net validator controls for all of my server side validation. I am using an errorlabelcontainer to store the client side validations in a summary at the top of the page, which is the requirement. All works well. My problem is, I want to display the server side asp.net errors in the same errorlabelcontainer OR display all of the client side errors in the validation summary. Either way, Both errors need to be in the same place/div. Any ideas on how to do this? I thought of maybe using the asp.net validation summary as the errorcontainer in JQuery, but I cannot find the summary. This is what I have right now.

View 1 Replies

Combine JQuery Client And Server Side Errors In Same Summary At Top Of Page

Feb 25, 2010

I am using JQuery for all of my client side validation and Asp.net validator controls for all of my server side validation. I am using an errorlabelcontainer to store the client side validations in a summary at the top of the page, which is the requirement. All works well. My problem is, I want to display the server side asp.net errors in the same errorlabelcontainer OR display all of the client side errors in the validation summary. Either way, Both errors need to be in the same place/div. Any ideas on how to do this? I thought of maybe using the asp.net validation summary as the errorcontainer in JQuery, but I cannot find the summary. This is what I have right now.

$("#aspnetForm").validate(
{
onkeyup: false,
errorLabelContainer: $("ul", $("#FormErrors")),
wrapper: "li"
});

If you need to see more code.

View 1 Replies

Unable To Serialize Session State - Server Errors

Oct 14, 2010

We have been receiving reports of the following server error periodically from users.
[OutOfMemoryException: Exception of type System.OutOfMemoryException was thrown.]
[HttpException (0x80004005): Unable to serialize the session state.]
Please note that non-serializable objects or MarshalByRef objects are not permitted when session state mode is "StateServer" or "SQLServer".

Once in a state where this error appears, it appears to be hit or miss whether the errors are reproducible locally. If they are, then we can usually reproduce them for a couple minutes, but not on every page hit. This usually tapers off on its own and usually has resolved itself by the time we get back in contact with the users. The Web Service has around 90-100 active connections during business hours. The only other site on this server is the staging version of this site, which gets hit very infrequently. The Session State is stored on the same SQLServer instance as the application database which is housed on a fairly large cluster of virtual machines.

Neither the Web Server or the SQLServer seemed to be taxed (either processor or memory-wise) while this is going on. The distribution of which pages are erroring seems to be comparable to the normal distribution for each page. There doesn't appear to be any pattern in terms of times of occurrence. We do have less errors on average on weekends (which correlates to normal site load), but even this appears to not be consistent. There also doesn't appear to be a correlation between the errors logged and any kind of logged performance monitor events. This includes an array of perfmon counters including:

.NET CLR Jit(w3wp)
otal # of IL Bytes Jitted
.NET CLR Jit(w3wp)IL Bytes Jitted / sec
.NET CLR Jit(w3wp)\% Time in Jit
.NET CLR Jit(w3wp)# of Methods Jitted
.NET CLR Jit(w3wp)# of IL Bytes Jitted
ASP.NET Apps v1.1.4322(__Total__)Requests Failed
ASP.NET Apps v1.1.4322(__Total__)Errors Unhandled During Execution/Sec
ASP.NET Apps v1.1.4322(__Total__)Errors Unhandled During Execution
ASP.NET Apps v1.1.4322(__Total__)Cache Total Turnover Rate
ASP.NET Apps v1.1.4322(__Total__)Errors During Preprocessing
ASP.NET Apps v1.1.4322(__Total__)Errors During Execution
ASP.NET Apps v1.1.4322(__Total__)Requests Executing
ASP.NET Apps v1.1.4322(__Total__)Requests Total
ASP.NET Apps v1.1.4322(__Total__)Errors Total
ASP.NET Apps v1.1.4322(__Total__)Sessions Abandoned
ASP.NET Apps v1.1.4322(__Total__)Errors Total/Sec
ASP.NET Apps v1.1.4322(__Total__)Anonymous Requests/Sec
ASP.NET Apps v1.1.4322(__Total__)Requests/Sec
ASP.NET Apps v1.1.4322(__Total__)Session SQL Server connections total
ASP.NET Apps v1.1.4322(__Total__)Cache Total Hit Ratio
ASP.NET v1.1.4322Requests Current
ASP.NET v1.1.4322Request Execution Time
MemoryPages/sec
Bytes Total/sec
PhysicalDisk(_Total)Avg. Disk Queue Length
Processor(_Total)\% Processor Time
Web Service CacheFile Cache Hits %
Web Service CacheFile Cache Misses
Web Service CacheFile Cache Hits
Web Service(_Total)Current Connections
Web Service(_Total)Post Requests/sec)

The only pattern I can see in the logs doesn't correlate to the occurrence of these errors, but is the only pattern I can see. Looking at the perfmon logs we are seeing a pattern where the "Total # of IL Bytes Jitted", "IL Bytes Jitted / sec", "% Time in Jit", "# of Methods Jitted", and "# of IL Bytes Jitted" counters for the staging site (which shouldn't be getting any traffic) doesn't pull data for a 20-50 minute period after which there is an immediate spike in "IL Bytes Jitted / sec" and a jump in "% Time in Jit" for 2-20 minute of up to 99% for the main site.

View 1 Replies

Web Forms :: Client Javascript Runs But Then Page Errors Out When Clicking On A Control That Uses Postback

Sep 3, 2010

Using this script on a button click

[Code]....

After it is done, I can't click on my calendar control. I was hoping to add somethign that would force a refresh in the script, but nothing I do works.

View 2 Replies

State Management :: Add The Cached TreeView Control To Page, Nothing Happens. No Errors No Nothing?

Mar 24, 2011

I Have a TreeView that I populate from a DataTable.Once it has been populated, I Cache the Treeview.If I try to add the cached TreeView control to my page, nothing happens. No errors no nothing.If I create an empty TreeView control on the page and do a "Do Until" loop and add each node to that empty TreeView, that works! but only once. The next time it loops, for some reasion the CachedTree.Nodes.Count = 0.I can't see what I'm doing wrong.

[Code]....

View 4 Replies

Conversion Of Crystal Report Of Desktop Application To Web Application's Crystal Report

Jul 24, 2010

I have got a desktop application which was build in vs2005, now i am doing conversion of it to web application (vs2008). i have got around 40 crystal reports in it (desktop application).

tell me can i use them (rpt files) directly in web application or i will have to create all new reports?

View 1 Replies

State Management :: Application State And Session State?

Oct 2, 2010

User Interface: 2 Labels; 1 Buttons

Requirements: Create a Web Page in ASPx that will do the following:

1)One label will provide a count of how many times Button 1 has been clicked in the current session.

2)One label will provide a count of how many times Button 1 has been clicked by all users of the application. The Application Code for the Button should start at 100 (set this in the Global.asax file). this is what i have so far but i cant seem to get the application state to work properly.

aspx.vb

Partial Class _Default
Inherits System.Web.UI.Page
Dim clickcount As Integer

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Session("ClickCount") Is Nothing Then
clickcount = 0
Else
clickcount = CInt(Session("ClickCount"))
End If
If Not IsPostBack Then
If Request.Cookies("UserName") IsNot Nothing Then
Label1.Text = "Welcome Back " & Request.Cookies("UserName").Value & "."
End If
End If
Dim clickCounta As Integer = CInt(Application("ClickCount"))
End Sub
Protected Sub PostBackSession_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PostBackSession.Click
clickcount += 1
lblClkCnt.Text = "Current Click Count is " & clickcount
Application.Lock()
Dim clickCounta As Integer = CInt(Application("ClickCount"))
clickCounta += 1
Application("ClickCount") = clickCounta
Application.UnLock()
AppClick.Text = clickCounta
Dim nameCookie As New HttpCookie("UserName", _
TextBox1.Text)
nameCookie.Expires = Now.AddYears(1)
Response.Cookies.Add(nameCookie)
End Sub
Protected Sub PostBackSession_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles PostBackSession.PreRender
Session("ClickCount") = clickcount
Application("ClickCount") = clickcount
End Sub
End Class
global.asax
<script runat="server">
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim clickCounta As Integer = CInt(Application("ClickCount"))
Application.Add("ClickCount", 0)
End Sub
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
Dim clickCounta As Integer = CInt(HttpContext.Current.Application("ClickCount"))
End Sub
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
End Sub

View 3 Replies

Log Application Errors When CustomErros Is Set To On?

Nov 27, 2010

I have setup an MVC application to log errors with log4net. In my global.asax I catch Application errors using the Application_Error method (s_log is my logging manager which is a wrapper around Log4net).

protected void Application_Error(Object sender, EventArgs e)
{
Exception ex = Server.GetLastError().GetBaseException();
s_log.LogException(true, ex, "Application Error");
}

When customErrors is set to "Off" I get the yellow screen of death and can see the error in my log file. When customErrors is set to "On" I see my Error page (and the detailed error) but nothing is written in the log file (debugging doesn't hit the Application_Error).

Error.aspx

<h1>Sorry, an error occurred while processing your request.</h1>
<strong>Controller: </strong> <%= Model.ControllerName %><br />
<strong>Action: </strong> <%= Model.ActionName %>[code]....

View 2 Replies

MVC :: Can't Get Model Client Validation Messages Localized?

May 23, 2010

i am currently working on an asp.net mvc (.net 3.5 sp1) web app, that uses data annotations and client side validation. I would like to have localization enabled, thus i have implemented a localization mechanism for enabling site visitors select the locale they prefer, by overriding the Execute() controller action and setting the CurrentCulture appropriately (i get the culture to change to from the URL route parameters).

I tried implementing my model validation messages localization with no success. What i did was adding two resource files undeer my model App_LocalResoorces folder (one for my locale greek language Validation.el.resx and one for the default english language Validation.el.resx) and set the appropriate file properties ("Access Modifier" to "Public", "Build Action" to "Embedded Resource","CustomTool" to "PublicResXFileCodeGenerator" and "Custom Tool Namespace" to "ModelLocalRes". Then i added a RequiredFieldPrompt" name-value to both the resource files.

Then i tried modify the required validation attribute on my model's name metadata like this:

[Code]....

The problem is that i cannot get the localization working, since the error message gets displayed always for the english default locale, no matter the locale selected from the site visitor.

View 11 Replies

MVC Model State Validations

Mar 21, 2011

<%= Html.ValidationSummary("Account creation was unsuccessful. correct the errors and try again.") %>
</div>
<% using (Html.BeginForm("Register", "Account" , FormMethod.Post))
{ %>
<div>
<fieldset>
<legend>Account Information</legend>
<p>
<label for="username">User Name:</label>
<%= Html.TextBox("username") %>
<%= Html.ValidationMessage("username") %>
</p>
<p>
<label for="FirstName">First Name</label>
<%= Html.TextBox("firstName") %>
<%= Html.ValidationMessage("firstName") %>
</p>
<p>
<label for="LastName">Last Name</label>
<%= Html.TextBox("lastName") %>
<%= Html.ValidationMessage("lastName") %>
</p>
<p>
<label for="email">Email:</label>
<%= Html.TextBox("email") %>
<%= Html.ValidationMessage("email") %>
</p>
<p>
<label for="password">Password:</label>
<%= Html.Password("password") %>
<%= Html.ValidationMessage("password") %>
</p>
<p>
<label for="confirmPassword">Confirm password:</label>
<%= Html.Password("confirmPassword") %>
<%= Html.ValidationMessage("confirmPassword") %>
</p>
<p>
<label for="Role">Role:</label>
<%= Html.DropDownList("Role",((SelectList)ViewData["Roles"]),"--Select One---") %>
</p>
<p>

[Code....]

View 1 Replies

C# - Compile Errors On Deployed Web Application, But Not In The IDE?

Dec 30, 2010

In my deployed web application I am getting the following error:

CS0103: The name 'releaseLionButton_Click' does
not exist in the current context

It identifies this as the offending line:

<asp:Button ID="releaseLionButton" runat="server"
Text="Release the Lion!"
OnClick="releaseLionButton_Click"></asp:Button>

[code]...

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved