I have a mvc4 view form with some fields, let's say:
- User name
- Surname
- Age
- Code
below an example:
@{
var actionURL = "https://" + Request.Url.Host + Request.Url.PathAndQuery;
using (Html.BeginForm("AddUser", "Configure", FormMethod.Post), new { @action = actionURL })
{
...
@Html.TextBoxFor(model => model.UserViewModel.Name, null, new { id = "UserName" })
@Html.PasswordFor(model => model.UserViewModel.UserCode, new { id = "UserCode" })
...
<input id="submitUser" type="submit" value="Send" />
...
}
}
ConfigureController.cs:
[RequireHttps]
public ActionResult AddUser(UserViewModel model)
{
// Encrypt user code and store it in database
// Store in database the rest of user information as-is, without encrypting
}
Code field should be encrypted once user info is submited through internet but other fields are not necessary. Then once I recieve user info in the controller, I encrypt the code field and store it in the database. Other user information is stored in database as-is.
I want to encrypt the user code in server side not in client side.
My problem is that once submit button is clicked an error is thrown, a page is shown saying:
- Ensure web address https://... is correct
- Search the page with you search engine
- Update/Refresh the page in a few minutes
- Ensure TLS/SSL protocols are enabled by going to Tools->Internet Options->Advanced options->Configuration->Security
I have ensured that TLS and SSL protocols are enabled: SSL 3.0 and TLS 1.0 are enabled.
What's wrong? and how to send code encrypted to the mvc4 controller? I do not want to make changes in web.config.
I have tried other solutions like explained below, but nothing works for me:
building own action filter: ASP.NET MVC RequireHttps
using form action instead of html.beginform: How to change POST to SSL URL in MVC 4
but nothing works...