MVC ajax表单回发仅在Windows Azure中托管时才会显示新窗口

时间:2012-02-25 02:39:31

标签: jquery asp.net-mvc model-view-controller azure ajaxform

我有一个<div id="notesdiv"></div>,它是从ajax调用填充到局部视图的:

    @using (Html.BeginForm("Notes", "Contact", FormMethod.Post, new { id = "notesForm" }))
{
    @Html.ValidationSummary(true)

    <div id="NewNoteTextArea">@Html.TextArea("NoteContent", new { style = "width:98%" })</div>
    <div id="AddNoteButton">
        <input type="submit" value="Add Note" id="addNoteButton" />
    </div>   
}
<div id="NotesGrid">
    @Html.Grid(Model).Columns(column =>
{
...
}).Attributes(@class => "grid")

<script type="text/javascript">
    // wait for the DOM to be loaded
    $(document).ready(function () {
        // bind form and provide a simple callback function 
        $('#notesForm').ajaxForm(function (data) {
            $("#notesdiv").html(data);
            return false;
        });
    }); 
</script>

单击“添加注释”按钮后,应该刷新注释div而无需加载新页面。这适用于Asp.Net Dev Server,本地IIS甚至Azure开发模拟器,但在Windows Azure中托管时失败 - 它将notesdiv呈现在新页面中。

以下是ServiceConfiguration.Cloud.cscfg:

<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="WebMVC_Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="1" osVersion="*">
  <Role name="WebMVC">
    <Instances count="1" />
    <ConfigurationSettings>
      <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
    </ConfigurationSettings>
  </Role>
</ServiceConfiguration>

和ServiceDefinition.cscfg:

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="WebMVC_Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
  <WebRole name="WebMVC" vmsize="Small">
    <Sites>
      <Site name="Web">
        <Bindings>
          <Binding name="Endpoint1" endpointName="Endpoint1" />
        </Bindings>
      </Site>
    </Sites>
    <Endpoints>
      <InputEndpoint name="Endpoint1" protocol="http" port="80" />
    </Endpoints>
    <Imports>
      <Import moduleName="Diagnostics" />
    </Imports>
  </WebRole>
</ServiceDefinition>

我在这里缺少什么?谢谢!

0 个答案:

没有答案