0

I spent 2 hours tracing syntax error in below code. What might be the issue

<div id="generalError">
    <div>
        @{if (System.Web.HttpContext.Current.Session["statusCode"].ToString() == "500")
        {
            <img src="~/Content/Images/oops.png" />
        }
        else if (System.Web.HttpContext.Current.Session["statusCode"].ToString() == "404")
        {
            <img src="~/Content/Images/sad.png" />
        }
        else if (System.Web.HttpContext.Current.Session["statusCode"].ToString() == "401")
        {
            <img src="~/Content/Images/authError.png" />
        }
        else if (System.Web.HttpContext.Current.Session["statusCode"].ToString() == "419" || System.Web.HttpContext.Current.Session["statusCode"].ToString() == "408")
        {
            <img src="~/Content/Images/oops.png" />
        }
        else
        {
            <img src="~/Content/Images/oops.png" />
        }
        }
    </div>
    <div style="display:inline-block;vertical-align:top;width:600px;padding-left:50px;">
        <div style="color:#fff;font-size:36px;font-family:'Segoe UI Light'">
            Sorry, something went wrong.
        </div>
        <div style="color:#fff;font-size:16px;font-family:'Segoe UI';padding-top:12px;padding-bottom:5px;">
            @if (System.Web.HttpContext.Current.Session["statusCode"].ToString() == "500")
            {
                @Html.Raw(System.Web.HttpContext.Current.Session["errorMessage"].ToString());
            }
            else if (System.Web.HttpContext.Current.Session["statusCode"].ToString() == "419" || System.Web.HttpContext.Current.Session["statusCode"].ToString() == "408")
            {
                @: Timeout error.
                }
            else if (System.Web.HttpContext.Current.Session["statusCode"].ToString() == "404")
            {
                @: Page not found.
            }
            else if (System.Web.HttpContext.Current.Session["statusCode"].ToString() == "403")
            {
                @: Forbidden.
            }
            else if (System.Web.HttpContext.Current.Session["statusCode"].ToString() == "401")
            {
                @: Unauthorized error.
                }
            else
            {
                @Html.Raw(System.Web.HttpContext.Current.Session["errorMessage"].ToString());
            }

        </div>
    </div>
</div>
2
  • on which line number u get an error Commented Apr 7, 2014 at 7:20
  • What's the exact error message? Commented Apr 7, 2014 at 7:21

1 Answer 1

2

Simply remove "{" between @ and if ...

    @{if ==> @if
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.