Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
i have implemented encryption using this link
[^]

what i wanted to this like @Html.ActionLink("Details", "Details", new { id=item.StudentID }) but they used @Html.EncodedActionLink(item.QuestionText, "Index", "Answer", new { questionId = item.QuestionID }, null)

What I have tried:

using this link https://dotnettrace.net/2013/09/19/encrypt-and-decrypt-url-in-mvc-4/



@Html.EncodedActionLink( "Edit", "Employee", new { id = item.StudentID }, null)

@Html.ActionLink("Details", "Details", new { id=item.StudentID }) |
@Html.ActionLink("Delete", "Delete", new { id=item.StudentID })
Posted
Updated 27-May-16 5:21am
v2
Comments
Karthik_Mahalingam 27-May-16 6:16am    
its an extension method for encrypting the query string..
Rakib Ahmed 27-May-16 6:25am    
i want to pass data like this way @Html.ActionLink("Delete", "Delete", new { id=item.StudentID }) but they passed @Html.EncodedActionLink(item.StudentName, "Index", "Answer", new { id = item.StudentID }, null)
Karthik_Mahalingam 27-May-16 6:27am    
i have tested the article it works perfect.
follow the steps he has mentioned in the page..

Html.ActionLink is the out of box method, in that article he has written a new extension method with the name EncoddedActionLink, so in order to achieve that functionality you have to use that.
Rakib Ahmed 27-May-16 6:35am    
i want to go to edit page when i click @Html.EncodedActionLink(item.StudentName, "Edit", "Employee", new { id = item.StudentID }, null) any way bro?
Karthik_Mahalingam 27-May-16 10:58am    
Always use  Reply  button, to post Comments/query to the user, else the User wont get notified.

Since you finding difficult to follow the article in link, i am just making it simple for you.
Credits to the Author:

Follow the below steps:
Step 1:
Create a new class file (somename.cs) in you project and just copy paste the code from this[^], i tried pasting the code over here, it is not pasting properly.
so you can just replace the existing code in somename.cs file to the code which is available in the link.

Step 2:
Build your project once.
Step 3:
in the comments you have posted this piece of code
C#
@Html.EncodedActionLink(item.StudentName, "Edit", "Employee", new { id = item.StudentID }, null)

So the Controller Name is "Employee" and the Action is "Edit"
Go to EmployeeController -> Edit Action and add the [EncryptedActionParameter] attribute to the action as below

C#
 [EncryptedActionParameter]
 public ActionResult Edit(int? Id)
 {
// your code...
  }


Now it should work.
Note: In the article the author has used the below key for Encryption/Decryption, you can change it for your need.
C#
string key = "jdsg432387#";
 
Share this answer
 
Comments
asiftufail 26-Jun-22 6:11am    
@Html.EncodedActionLink(item.StudentName, "Edit", "Employee", new { id = item.StudentID }, null)
How to use asp.net mvc c# area in above link

@Html.EncodedActionLink(item.StudentName, "Edit", "Employee", new { id = item.StudentID, area="MyArea" }, null) this code not work
 
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