In visual studio 2013 MVC 4 I'm getting below mention error when calling action in controller
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
I need help to solve this. here my code
public class PasswordGeneratorController : BaseController
{
//
// GET: /PasswordGenerator/
public ActionResult PasswordGenerator()
{
PasswordGeneratorViewModel viewModel = new PasswordGeneratorViewModel();
ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
return View(Constant.ViewPasswordGenerator, viewModel);
}
public ActionResult Clear()
{
PasswordGeneratorViewModel VM = new PasswordGeneratorViewModel();
VM.strKeyValue = "";
VM.strPassword = "";
return View(Constant.ViewPasswordGenerator, VM);
}
public ActionResult GeneratePassword()
{
string strpassword = string.Empty;
PasswordGeneratorViewModel VM = new PasswordGeneratorViewModel();
TryUpdateModel(VM);
try
{
if (VM.strKeyValue.ToString().Trim() != "")
{
ModelState.Remove("strPassword");
strpassword = VM.strKeyValue.ToString().Trim() + CurrentUserName.ToString().Trim();
//strpassword = VM.strKeyValue.ToString().Trim() + "reyazmihular";
VM.strPassword = this.Encrypt(strpassword, "");
}
return View(Constant.ViewPasswordGenerator, VM);
}
catch (Exception ex)
{
throw ex;
}
}
private string Encrypt(string password, string salt)
{
//byte[] passwordBytes = Encoding.Unicode.GetBytes(password);
//byte[] saltBytes = Encoding.Unicode.GetBytes(salt);
//byte[] cipherBytes = ProtectedData.Protect(passwordBytes, saltBytes, DataProtectionScope.CurrentUser);
//return Convert.ToBase64String(cipherBytes);
string strmsg = string.Empty;
byte[] encode = new byte[password.Length];
encode = Encoding.UTF8.GetBytes(password);
strmsg = Convert.ToBase64String(encode);
return strmsg;
}
private string Decrypt(string password, string salt)
{
password = "NTk2MDY4MjNyZXlhem1paHVsYXI=";
string decryptpwd = string.Empty;
UTF8Encoding encodepwd = new UTF8Encoding();
Decoder Decode = encodepwd.GetDecoder();
byte[] todecode_byte = Convert.FromBase64String(password);
int charCount = Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
char[] decoded_char = new char[charCount];
Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
decryptpwd = new String(decoded_char);
return decryptpwd;
}
}
------------------------------------------------------------------------
View
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="KPMG.PasswordGenerator.Web.Common.BaseViewPage" %>
<%@ Import Namespace="KPMG.PasswordGenerator.Web.App_LocalResources" %>
<%@ Import Namespace="KPMG.PasswordGenerator.Web.Common" %>
<%@ Import Namespace="KPMG.PasswordGenerator.Web.Models" %>
function GeneratePassword() {
document.forms[0].submit();
}
<%=Html.ValidationSummary()%>
<% Html.BeginForm(Constant.ActionGeneratePassword, Constant.ControllerPasswordGenerator, FormMethod.Post, new { id = "submitForm" }); %>
<%=PasswordGeneratorViewResource.KeyLabel%>
<%=PasswordGeneratorViewResource.MandatoryLabel%>
<%=Html.TextBoxFor(model => model.strKeyValue, new {maxlength = "300",@class=Constant.CssClassMandatoryField })%>
<%=PasswordGeneratorViewResource.PasswordLabel%>
<%=PasswordGeneratorViewResource.MandatoryLabel%>
<%=Html.TextAreaFor(model => model.strPassword, new {style = "width:1050px;height:50px",maxlength = "300",@class=Constant.CssClassMandatoryField })%>
<% Html.EndForm();%>
10 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Francis SusaimichaelPosted Jan 18, 2016, 5:15 AM
Duminda DissanayakePosted Jan 18, 2016, 3:13 AM
Duminda DissanayakePosted Jan 18, 2016, 3:13 AM
Francis SusaimichaelPosted Jan 18, 2016, 2:42 AM
Duminda DissanayakePosted Jan 18, 2016, 2:03 AM
Francis SusaimichaelPosted Jan 14, 2016, 2:22 AM
Duminda DissanayakePosted Jan 14, 2016, 12:27 AM
Francis SusaimichaelPosted Jan 12, 2016, 5:49 AM
Duminda DissanayakePosted Jan 12, 2016, 5:04 AM
Francis SusaimichaelPosted Jan 12, 2016, 4:54 AM