我想让Glimpse让我看看POST动作过程中发生了什么,在POST动作中由“return RedirectToAction()”触发的GET动作之前发生了什么。我发现this SO post解释为:试图查看POST信息与掠影
您可以使用Glimpse的远程选项卡查看过去的请求。
单击远程选项卡,然后选择右侧的“启动”链接。然后这个 将向您显示该客户在 时间内发出的请求列表。
从该列表中,您可以点击“Launch”链接查看给定的 请求,查看过去请求的所有Glimpse信息(包括日志记录) 。这在Glimpse中通过更改URL更改 和显示在左上角/状态 区域中的字符串“(远程)”来记录。
我的问题是,如果我POST不止一次,瞥见似乎只想让我通过“远程”选项卡访问第一个POST。换句话说,当我与我的网站进行交互时,我想看看最近一次POST中发生了什么,但是似乎只想告诉我在第一次POST期间发生了什么。
通过测试这种行为方式,我创建了一个简单的MVC应用程序(我已经这样做了同样的方法,用MVC 3和4 MVC都与大致相同的结果):
- 在Visual Studio 2012,创建一个新的APS.NET MVC 3 Web应用程序并将其命名为MVC3App
- 选择互联网应用
- 右键单击Solution Explorer中的项目,选择管理的NuGet软件包,并为ASP.NET MVC3(测试版)安装掠影(版本0.87)
修改HomeController.cs看起来像这样
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Diagnostics;
using MVC3App.Models;
namespace MVC3App.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Message = "My test";
// Initialize the model data
if (Session["value"] == null) Session["value"] = 1;
// Get a view model
var mvm = new MyViewModel() {
Value = Convert.ToInt32(Session["value"])
};
// Display the view
return View(mvm);
}
[HttpPost]
public ActionResult Index(MyViewModel mvm)
{
Trace.TraceInformation("POST: Value = {0}", mvm.Value);
// Fetch the POST data and store it in the model data
Session["value"] = mvm.Value;
// Redirect back to the "display" page
return RedirectToAction("Index");
}
public ActionResult About()
{
return View();
}
}
}
添加型号\ MyViewModel.cs
namespace MVC3App.Models
{
public class MyViewModel
{
public int Value { get; set; }
}
}
,并最终修改Index.cshtml
@model MVC3App.Models.MyViewModel
@{
ViewBag.Title = "Home Page";
}
@using (Html.BeginForm()) {
<div>
Value: @Html.EditorFor(m => m.Value)
</div>
<input type="submit" value="Click me" />
}
当您运行项目,你会得到一个包含“1”的文本框的网页。将值更改为“123”,然后单击“单击我”按钮。
现在,如果您在网页上显示Glimpse面板,您会看到它显示的信息大概来自显示该页面的GET请求。如果我点击远程选项卡,它会显示3个请求以及一个启动链接。如果我点击Launch链接,然后点击列表中POST请求旁边的Launch链接,它将显示POST中包含值“123”的数据。
现在,将网页上的值更改为“5”,然后单击“单击我”按钮。好的,现在我想在POST数据中看到来自POST请求的数据值为5。在“掠景”面板的“远程”选项卡上,您会看到它仍然有3个可用的远程请求。点击启动链接显示相同的原始3个远程请求。它不会显示我通过单击按钮触发的POST请求。
那么,我在这里错过了什么?我认为这应该工作,我只是滥用它在某种程度上...(我想我要补充一点,我使用的是IE浏览器在Windows 7中)
鲍勃
当我安装Glimpse RC1时,Glimpse完全消失。执行我现有的书签scriptlet(启用Glimpse)不启用它。导航到MyURL/glimpse.axd会返回“404 - 未找到”。我在两个不同的MVC 4应用程序中尝试了这一结果。 –
更新:在这两种情况下(上述),我都没有先删除现有的Glimpse软件包,而是安装了Glimpse并安装了Glimpse RC1的项目。安装者声称它为我删除了早先的Glimpse软件包。我会尝试在今天晚些时候的一个新的项目中添加Glimpse RC1 ... –
您是否正在安装'Glimpse.MVC3'项目?或者只是'瞥见'。 – nikmd23