Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
try
{
if (storeView.storeid == 0)
{
//check if usernamne exists
WebSecurity.CreateUserAndAccount(StoreModel.UserName, StoreModel.Password);
}
}
//if user doesn't exists comes here and i want to display the error i added in modelstate in view.
catch (MembershipCreateUserException e)
{
ModelState.AddModelError("UserName", "Entered User exists");
return View(storeModel);
}


//unable to display error in view not showing error through @Html.ValidationMessage, showing Yellow screen of Death
Posted
Updated 4-Nov-15 19:10pm
v3
Comments
MayankSemwal 4-Nov-15 3:43am    
Somebody there.?
Richard Deeming 4-Nov-15 13:19pm    
There's lots of people here, but you have to actually describe the problem before anyone can help you.

Use the "Improve question" button to update your question. Include a description of what you're trying to do, what you've tried, and what's not working. If you're getting an exception, include the full exception details and the code that throws the exception. Remember to indicate which line in your code the exception is thrown from.
MayankSemwal 5-Nov-15 1:10am    
Is it okay now.
Richard Deeming 5-Nov-15 7:47am    
So you're getting an unhandled exception? You need to post the full details of the exception, and include the code that throws the exception.

If you can't get the details from the YSOD, then they'll be logged in the Application event log on the server.
MayankSemwal 6-Nov-15 0:31am    
getting exception for username already exists at catch. but not able to display that on view.. Exception is "Value cannot be null parameter source"

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900