The provided anti-forgery token was meant for user “”, but the current user is “user@example.com”

While working with Asp.net MVC, I got HttpAntiForgeryException exception (The provided anti-forgery token was meant for user “”, but the current user is “user@example.com”) at login page. It happens when user login with valid credentials and re-directed to inner page ofr the application. At inner pages he press the browser back button and will show login page again. He entered the valid credentials again that time, this exception will generate and display on the browser.

To fix this exception: Need to add [OutputCache(NoStore=true, Duration = 0, VaryByParam= “None”)] line to your login get method.

[AllowAnonymous]
[HttpGet]
[OutputCache(NoStore=true, Duration = 0, VaryByParam= "None")]
public ActionResult Login(string returnUrl)
{
ViewBag.ReturnUrl = returnUrl;
return View();
}

remove duplicate values from a excel cell

Microsoft Excel is used by everyone in the world for all data related things, some time we have duplicate cell contents in rows or in columns.

To remove these duplicate values from the sheet we already have a feature “Remove Duplicates” in latest version of the excel application. But if we have some duplicate values in a single cell then this feature will not work, we need some another alternative, either we delete manually or can create a Macro / Addins / Custom Function.

Manual process will not help because it required lot of concentration,? To resolved that I have created a Addins which we can integrate in excel application and access this custom function like other we generally used.

Steps to create addins:
– Go to View – > Macro
– Define Name “RemoveDuplicatesFromCell” and click on create Button
– Add the following code at Module1 file
– Save the file as RemoveDuplicatesFromCell.xla
[vbnet]
Function RemoveDuplicatesFromCell(txt As String, Optional delim As String = ” “) As String
Dim x
With CreateObject(“Scripting.Dictionary”)
.CompareMode = vbTextCompare
For Each x In Split(txt, delim)
If Trim(x) <> “” And Not .exists(Trim(x)) Then .Add Trim(x), Nothing
Next
If .Count > 0 Then RemoveDuplicatesFromCell= Join(.keys, delim)
End With
End Function
[/vbnet]