I used the below guide to encrypt the URL in my mvc app. I do see that the values are encrypted but I am getting the IIS error saying the page or resource you are looking for is not found. I m thinking it has something to do with the routing. I m completely new to MVC so I tried couple of different route combinations but nothing works. To add to this, when debugging I cant get my Application_Start event to get hit,so i m not able to debug it as well. My route.config file is given below. Could somebody please help me with the issue ?
The URL that is generated after the encryption is this. My route.config file is given below.
http://www.dotnettrace.net/2013/09/encrypt-and-decrypt-url-in-mvc-4.html
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Test",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "TESTVIEW", id =
UrlParameter.Optional }
);
routes.MapRoute(
name: "Invoice",
url: "{controller}/{action}/{q}",
defaults: new { controller = "Home", action = "GetInvoice", id =
UrlParameter.Optional }
);
routes.MapRoute(
name: "Error",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Error", id =
UrlParameter.Optional }
);
routes.MapRoute(
name: "ResetPassword",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "ResetPassword", id
= UrlParameter.Optional }
);
routes.MapRoute(
name: "Accounts",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "AccountStatus", id
= UrlParameter.Optional }
);
routes.MapRoute(
name: "Register",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Register", id =
UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Login", id =
UrlParameter.Optional }
);
}
please let me know where am I doing wrong.
My action is below.
[EncryptedActionParameter]
public FileStreamResult GetInvoice(string accountNumber,string dueDate)
{
// Set up the document and the MS to write it to and create the PDF
writer instance
//MemoryStream ms = new MemoryStream();
//Document document = new Document(PageSize.A4.Rotate());
//PdfWriter writer = PdfWriter.GetInstance(document, ms);
// Set up fonts used in the document
Font font_heading_1 = FontFactory.GetFont(FontFactory.TIMES_ROMAN,
19, Font.BOLD);
Font font_body = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 9);
SBLWebSite.SBLCustomerService.CustomerServiceClient client = new
SBLWebSite.SBLCustomerService.CustomerServiceClient();
byte[] file = client.GetInvoice(accountNumber, dueDate).Invoice;
MemoryStream output = new MemoryStream();
output.Write(file, 0, file.Length);
output.Position = 0;
HttpContext.Response.AppendHeader("content-disposition", "inline;
filename=file.pdf");
// Return the output stream
return new FileStreamResult(output, "application/pdf");
}