나는 Glimpse MVC4 버전 1.2.0을 사용하고 있습니다.엿볼 모델 바인딩 탭이 비활성화 된 이유는 무엇입니까?
브라우저에서 Glimpse UI를 열면 "모델 바인딩"탭이 비활성화되어 있습니다. 나는 그것을 가능하게하는 방법을 볼 수 없다. Glimpse docs 읽기하면 탭
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<tabs>
<ignoredTypes>
<add type="{Namespace.Type, AssemblyName}"/>
</ignoredTypes>
</tabs>
</glimpse>
을 무시할 수 있음을 보여하지만 내 Web.config의에서 그 아무도 없어 :
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<section name="glimpse" type="Glimpse.Core.Configuration.Section, Glimpse.Core" />
</configSections>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<httpRuntime targetFramework="4.5" />
<compilation debug="true" targetFramework="4.5" />
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
<!-- Glimpse: This can be commented in to add additional data to the Trace tab when using WebForms
<trace writeToDiagnosticsTrace="true" enabled="true" pageOutput="false"/> -->
<httpModules>
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" />
</httpModules>
<httpHandlers>
<add path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<add name="Glimpse" path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" preCondition="integratedMode" />
</handlers>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" preCondition="integratedMode" />
</modules>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<!-- If you are having issues with Glimpse, please include this. It will help us figure out whats going on.
<logging level="Trace" /> -->
</glimpse>
</configuration>
다른 모든 탭이 활성화됩니다. 누군가이 탭이 사용 중지 된 이유를 제안 할 수 있습니까?
편집 : "세션"탭도 비활성화되어 있습니다.
아 좋아, Session["Testing"] = "123"
전화를 추가 한 후 이제 '세션'탭이 사용 설정되었습니다. 그래도 "모델 바인딩"탭을 사용할 수 없습니다. 여기에 포스트 백에 내보기 코드입니다 :
[HttpPost]
public ActionResult Index([ModelBinder(typeof(MyModelBinder))]HomeIndexViewModel viewModel)
{
return this.View(viewModel);
}
public class MyModelBinder : IModelBinder
{
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
var viewModel = new HomeIndexViewModel();
viewModel.Name = "From model binder.";
return viewModel;
}
}
PRG 아이디어를 사용하여, 나는 지금처럼 내 코드를 다시 쓴 : 내가 가진 문제가
[HttpPost]
public ActionResult Index([ModelBinder(typeof(MyModelBinder))]HomeIndexViewModel viewModel)
{
return this.RedirectToAction("SaveSuccess");
}
public ActionResult SaveSuccess(HomeIndexViewModel viewModel)
{
return this.View();
}
기록 탭에서 내가 할 수있는, 그 사용중인 DefaultModelBinder를 보여주는 "SaveSuccess"요청을 검사 할 때 "Model Binder"가 활성화되어 있는지 확인하십시오. 그러나 내 사용자 지정 모델 바인더를 사용하는 내 인덱스 요청은 탭을 활성화하지 않습니다.
나는이 문제가 귀하가 언급 한 PRG라고 생각합니다. 방금 액션 메소드에 AJAX POST 요청을했고 "Model Binding"탭이 활성화되었습니다 (요청에 대한 "History"탭에서 Inspect를 클릭 한 후). 'Index' 액션 메소드로 문제를 해결할 수 있다는 것을 보여줄 수 있습니까? 내가 도대체 뭘 잘못하고있는 겁니까? –
당신이 옳았습니다. 나는 여기에 주어진 샘플을 따라 갔다 : http://judeokelly.com/implementing-prg-post-redirect-get-in-asp-net-mvc/ 이제 모델 바인딩 탭을 사용할 수있다. –
죄송합니다, 나는 대답을 받아 총을 들고 뛰었습니다. DefaultModelBinder를 사용할 때 "모델 바인딩"탭을 분석 할 수는 있지만 고객 모델 바인더를 사용하여 요청하면 탭이 활성화되지 않습니다. 지금 시도하고있는 것을 반영하도록 코드를 업데이트했습니다. –