Azure在Razor视图中显示语法错误,但在localhost中显示页面加载

时间:2015-05-21 17:00:12

标签: asp.net-mvc azure razor syntax-error azure-web-sites

我有一个在windows azure中运行的网站应用程序,但是,当我在应用程序中登录时,Azure会向我返回错误500

Azure网站事件查看器扩展名上,有以下例外:

    Exception type: HttpParseException
    Exception message: The if block is missing a closing "}" character.
              Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.

Request information:

    Request URL: http://independentmusicstore.azurewebsites.net/Music

    Request path: /Music

    User host address: 177.203.93.129

    User: pedro

    Is authenticated: True

    Authentication Type: Forms

    Thread account name: IIS APPPOOL\independentmusicstore

这是登录后发生错误500的视图:

@model IEnumerable<TestTcc2.Models.Musica>

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutMusico.cshtml";
}

<script src="Content/audiojs/audio.min.js"></script>
<div class="row">
<div class="col-md-4"></div>
<div id="divAudio" class="col-md-4">

    <audio id="audioPlay" src="x" preload="auto" onplay="true" />
    <script>
        audiojs.events.ready(function () {
            var as = audiojs.createAll({
                autoplay: true,
                autoload: "none"
            });

        });

        function replaceAll(str, de, para) {
            var pos = str.indexOf(de);
            while (pos > -1) {
                str = str.replace(de, para);
                pos = str.indexOf(de);
            }
            return (str);
        }

        function getUrlParameter(sParam) {
            var sPageURL = window.location.search.substring(1);
            var sURLVariables = sPageURL.split('&');
            for (var i = 0; i < sURLVariables.length; i++) {
                var sParameterName = sURLVariables[i].split('=');
                if (sParameterName[0] == sParam) {
                    var rep = replaceAll(sParameterName[1], "%2F", "/");
                    rep = replaceAll(rep, "%20", " ");
                    return rep;
                }
            }
        }
        var x = getUrlParameter('path');
        $('#audioPlay').attr('src', x);
    </script>
</div>
<div class="col-md-4"></div>
</div>
<br />
<p>
    @Html.ActionLink("Create New", "Create")
</p>

<table class="table table-hover table-bordered">
    <tr>
        <th>
            <span>Genero</span>
        </th>

        <th>
            <span>Nome</span>
        </th>
        <th>
            <span>Artista</span>
        </th>
        <th>
            <span>Preço</span>
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    if (item.UserId == Int32.Parse(Membership.GetUser().ProviderUserKey.ToString()))
    {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.genero.Nome)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Nome)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.NomeArtista)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Preco)
        </td>
        <td>
            @Html.ActionLink("Play", "", new { path = item.path }) |
            @Html.ActionLink("Edit", "Edit", new { id=item.MusicaId }) |
            @Html.ActionLink("Download", "Download", new { path = item.path }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.MusicaId })
        </td>
    </tr>
}
}

</table>

正如您所看到的,没有任何{}不正确,我该如何解决?

这是我从azure

中记录的详细错误
Detailed Error Information:
Module    ManagedPipelineHandler 
Notification    ExecuteRequestHandler 
Handler    System.Web.Mvc.MvcHandler 
Error Code    0x00000000 
Requested URL    http://independentmusicstore:80/Music 
Physical Path    D:\home\site\wwwroot\Music 
Logon Method    Forms 
Logon User    pedro

1 个答案:

答案 0 :(得分:0)

我会移动

if (item.UserId == Int32.Parse(Membership.GetUser().ProviderUserKey.ToString()))
{

代码到控制器并传递授权数据的视图模型。