CopyPastor

Detecting plagiarism made easy.

Score: 0.8985472624394646; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2021-06-16
by Tupac

Original Post

Original - Posted on 2018-03-22
by Marco



            
Present in both answers; Present only in the new answer; Present only in the old answer;

TempData is designed to have a life span only in between the current and the next request. You'd have to re-store it on every request (or call .Keep()) to make it available on the subsequent request. You would be better of using a Session object or retrieving it from your user identity.
However you can "keep" your TempData object, if you call .Keep() after calling it (displaying counts towards calling).
<li class="nav-item"> <h5 style="color:white"> Welcome, @TempData["username"]</h5> @TempData.Keep("username") </li> Yet another way to circumvent this, is to use .Peek():
<li class="nav-item"> <h5 style="color:white"> Welcome, @TempData.Peek("username").ToString()</h5> </li>
TempData is designed to have a life span only in between the current and the next request. You'd have to re-store it on every request (or call `.Keep()`) to make it available on the subsequent request.
You would be better of using a Session object or retrieving it from your user identity.
However you can "keep" your TempData object, if you call `.Keep()` after calling it (displaying counts towards calling).
<li class="nav-item"> <h5 style="color:white"> Welcome, @TempData["username"]</h5> @TempData.Keep("username") </li>
Yet another way to circumvent this, is to use `.Peek()`:
<li class="nav-item"> <h5 style="color:white"> Welcome, @TempData.Peek("username").ToString()</h5> </li>

        
Present in both answers; Present only in the new answer; Present only in the old answer;