Application insight request fails even though the code is working properly

安稳与你 提交于 2019-12-24 11:21:05

问题


I have an action method which is working as I expect. Here is the code:

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "Id,Title,Content,Category,HeaderFilePath")] Blog blog, HttpPostedFileBase upload)
{
    if (ModelState.IsValid)
    {
        if (upload != null && upload.ContentLength > 0)
        {
            if (blog.HeaderFilePath != string.Empty && blog.HeaderFilePath != null)
            {
                try
                {
                    System.IO.File.Delete(HttpContext.Server.MapPath("~/") + "images/" + blog.HeaderFilePath);
                }
                catch (Exception)
                {
                    //TODO: handle it properly
                    //throw;
                }
            }
            blog.HeaderFilePath = Guid.NewGuid() + ".jpg";
            CustomHttpPostedFile f = new CustomHttpPostedFile(upload.InputStream, "jpg", HttpContext.Server.MapPath("~/") + "images/" + blog.HeaderFilePath);
            f.SaveAs(HttpContext.Server.MapPath("~/") + "images/" + blog.HeaderFilePath);
        }
        db.Entry(blog).State = EntityState.Modified;
        db.SaveChanges();
        return RedirectToAction("Index");
    }
    return View(blog);
}

This Action method is doing its job no problem, Am I missing something?

The sign above the method body looks like "0 references | 1 request, 100% failed | 0 exceptions".

When i click on it it doesnt provide me any usefull information.

Edit: here is the screenshot showing no information for the failed request.

来源:https://stackoverflow.com/questions/40847828/application-insight-request-fails-even-though-the-code-is-working-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!