toemail will always be null.
You need to set the name attribute for input: "toemail" to make it related.
<input type="text" id="toemail" name="toemail" />
Never, as others say, it makes no sense to use empty statements. This hides a potential error. As in your case, there is a hidden exception in the try catch , which leads to the result of a null action, so a blank screen appeared.
There are several options for handling exceptions in ASP MVC. My favorite is a combination of an exception filter and settings <CustomErrors mode="On"/> web.config.
protected override void OnException(ExceptionContext filterContext) { base.OnException(filterContext); if (filterContext.HttpContext.IsCustomErrorEnabled) { if (filterContext.Exception is SecurityException) { filterContext.ExceptionHandled = true; filterContext.Result = View("FriendlyError");
Therefore, when a custom error is enabled, you can return a friendly production error screen or disable it to see the actual exception during debugging.
source share