Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC RedirectToAction from one controller to another - View is not displayed issue
    primarykey
    data
    text
    <p>I have a controller in which is do some checks.</p> <p>If for one reason or another and exception occurs I want to display the error messages in another view in another controller.</p> <p>This is how my exception handler looks</p> <pre><code> catch (Exception ex) { string infoMsg = "Delete the user and recreate is with an appropriate username of both a first and last name which is required for a doctor"; string errorMsg = ex.Message; // ErrorController ec = new ErrorController(); return this.RedirectToAction("Index", "Error", new { errorMessage = errorMsg, infoMessage = infoMsg }); } </code></pre> <p>This is ActionResult the receives the call.</p> <pre><code> public ActionResult Index(string errorMessage, string infoMessage) { var db = new DB(); OccuredError occuredError = new OccuredError(); occuredError.ErrorMsg = errorMessage; occuredError.InfoMsg = infoMessage; DateTime dateTime = DateTime.Now; occuredError.TimeOfError = dateTime; db.OccuredErrors.InsertOnSubmit(occuredError); db.SubmitChanges(); return View(occuredError); } </code></pre> <p>This is the error Index view which is strongly typed</p> <pre><code>&lt;h2&gt;Index&lt;/h2&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;&lt;/th&gt; &lt;th&gt; Error Message &lt;/th&gt; &lt;th&gt; Info Message &lt;/th&gt; &lt;th&gt; Time Of Error &lt;/th&gt; &lt;/tr&gt; &lt;% foreach (var item in Model) { %&gt; &lt;tr&gt; &lt;td&gt; &lt;%= Html.ActionLink("Details", "Details", new { id=item.ErrorId })%&gt; | &lt;/td&gt; &lt;td&gt; &lt;%= Html.Encode(item.ErrorId) %&gt; &lt;/td&gt; &lt;td&gt; &lt;%= Html.Encode(item.ErrorMsg) %&gt; &lt;/td&gt; &lt;td&gt; &lt;%= Html.Encode(item.InfoMsg) %&gt; &lt;/td&gt; &lt;td&gt; &lt;%= Html.Encode(String.Format("{0:g}", item.TimeOfError)) %&gt; &lt;/td&gt; &lt;/tr&gt; &lt;% } %&gt; &lt;/table&gt; </code></pre> <p></p> <p> </p> <p>My problem is that the User is NOT redirected from the initial view (The one that had the exception) to the Error index view. When debugging I can see that it runs through the Error Index ActionResult fine and the data is put in the DB. There is just something with the displaying of the Index view that cause the problem I think.</p> <p>Any suggestions to what I am doing wrong here.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload