我需要在MVC项目的另一个项目中显示图像。从MVC访问图像时,我需要在路径中返回一个文件夹(或不需要View文件夹名称)。以下是视图Views \ Booking
的控制器代码 public virtual ActionResult ResendEticket(BookingViewModel resendTicketModel)
{
if (ModelState.IsValid)
{
if(!string.IsNullOrEmpty(resendTicketModel.Email))
{
BookingService resendEticket = new BookingService();
string result = resendEticket.ResendEticket(Convert.ToInt32(resendTicketModel.BookingReference), resendTicketModel.Email);
if(!string.IsNullOrEmpty(result))
{
ModelState.AddModelError(string.Empty, result);
}
}
}
ModelState.AddModelError(string.Empty, "Unable to do resend ticket due to system error");
return RedirectToAction("Index", "Booking");
}
我目前在接收方获得的路径是 C:\ Projects \ Booking \ Invoices \ Templates \ images \ logo_eticket.png
我需要的是 C:\ Projects \ Invoices \ Templates \ images \ logo_eticket.png
在接收方,我使用以下代码
TaxInvoiceFilePath = HttpContext.Current.Server.MapPath(mtxr.TaxInvoiceFilePath);
我可能无法更改上面的任何内容,因为这是与其他应用程序共享的。 我怎样才能将HttpContext.Current.Server.MapPath向后移一步以便一切正常