开发者

MVC 3 Razor view renders different on hosting environment than locally

开发者 https://www.devze.com 2023-04-03 06:24 出处:网络
I have created an MVC 3 view, just by adding a controller and scaffold it by usage of entity framework.

I have created an MVC 3 view, just by adding a controller and scaffold it by usage of entity framework.

See below view:

<table>
    <tr>
        <th>
            MetaType
        </th>
        <th>
            Value
        </th>
        <th>
            Page
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.MetaType)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Value)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Page.Title)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
            @Html.ActionLink("Details", "Details", new { id=item.Id }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.Id })
        </td>
    </tr>
}

</table>

When I open the view on my dev machine than the html produced is just as expected:

<table>
    <tr>
        <th>
            MetaType
        </th>
        <th>
            Value
        </th>
        <th>
            Page
        </th>
        <th></th>
    </tr>

    <tr>
        <td>
            Keywords
        </td>
        <td>
            bla, bla bla,
        </td>
        <td>
            Home
        </td>
        <td>
            <a href="/Admin/metainformation/Edit/1">Edit</a> |
            <a href="/Admin/metainformation/Details/1">Details</a> |
            <a href="/Admin/metainformation/Delete/1">Delete</a>
        </td>
    &l开发者_开发技巧t;/tr>

On our hosting environment it's rendered with on almost every row an extra whiteline.

<table>

<tr>

<th>MetaType</th>

<th>Value</th>

<th>Page</th>

<th></th>

</tr>

<tr>

<td>Keywords</td>

<td>values, values, values.</td>

<td>Home</td>

<td><a href="/Admin/metaInformation/Edit/1">Edit</a> | <a href="/Admin/metaInformation/Delete/1">Delete</a></td>

</tr>

Anyone has an idea why there is a difference, and how to resolve this extra whitespace?

UPDATE It seems like only this page is having this issue. Other pages just have a normal html layout as expected. I also have checked the data from the database, but can't find anything unusual or different than the other pages.

I have also tried to regenerate the file and upload it again, but also no luck. I'm a bit out of options on this issue.


When something different in a host comparing to your environment, it's usually one of the following issues:

  1. Time and/or DateTime Format of server is different from your local machine
  2. Global application culture and/or encoding is different
  3. Databases (MS-SQL) has a different collisions

I suggest you to add the following node to both your local and host web.config, and check the result:

<configuration>
   <system.web>
      <globalization
         requestEncoding="utf-8"
         responseEncoding="utf-8" />
   </system.web>
</configuration>


After a doing a republish of my application the issue has dissapeared. Haven't found what's causing it.

0

精彩评论

暂无评论...
验证码 换一张
取 消