我对MVC(当前的Web窗体开发人员)非常陌生,我很难为视图分配值。谁能告诉我我做错了什么?
该应用程序应输出加密或解密的字符串。
这是我的控制人员:
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);
}
我的观点:
<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>
}
提前致谢!