I'm very new to MVC (current Web Forms developer), I'm having difficulty assigning values to the view. Can anyone tell me what I did wrong?
The app is supposed to output the encrypted or decrypted string.
Here's my controller:
public ActionResult Index(EncryptionModel encryption)
{
string Key = encryption.Key;
string EncryptString = encryption.EncryptString;
string DecryptString = encryption.DecryptString;
string Output = encryption.Output;
var process = new EncryptionModel();
if (!String.IsNullOrEmpty(EncryptString))
{
process.Output = StringCipher.Encrypt(EncryptString, Key);
}
else
process.Output = StringCipher.Decrypt(DecryptString, Key);
return View("Index",process);
}
My view:
<body>
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
<table cellpadding="0" cellspacing="0">
<tr>
<th colspan="2" align="center">Encrypt and Decrypt</th>
</tr>
<tr>
<td>Key: </td>
<td>
@Html.TextBoxFor(m => m.Key)
</td>
</tr>
<tr>
<td>Encrypt String: </td>
<td>
@Html.TextBoxFor(m => m.EncryptString)
</td>
</tr>
<tr>
<td>Decrypt String: </td>
<td>
@Html.TextBoxFor(m => m.DecryptString)
</td>
</tr>
<tr>
<td>Output: </td>
<td>
@Html.TextBoxFor(m => m.Output)
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
}
Thanks in advance!