Как поставить тэг META в начале секции HEAD HTML ответа

60 views
Skip to first unread message

pru...@yandex.ru

unread,
Sep 2, 2014, 7:29:21 AM9/2/14
to ext...@googlegroups.com
ExtNet  добавляет свои записи в начало секции HEAD, таким образом тэг META сдвигается ниже. А для корректной работы тэга META в IE9+ необходимо чтобы  он стоял перед всеми остальными тэгами секции HEAD за исключением тэга TITLE.

Файл _Layout.cshtml:

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>@ViewBag.Title</title>


Это пришло в браузер:

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <link type="text/css" rel="stylesheet" href="/extjs/resources/ext_theme_classic/ext-theme-classic-all-embedded-css/ext.axd?v=41064" id="ext-theme" />
    <link type="text/css" rel="stylesheet" href="/extnet/resources/css/extnet-all-embedded-css/ext.axd?v=41064" id="extnet-styles" />
    <script type="text/javascript" src="/extjs/ext-all-js/ext.axd?v=41064"></script>
    <script type="text/javascript" src="/extnet/extnet-all-js/ext.axd?v=41064"></script>
    <script type="text/javascript" src="/extnet/locale/ext-lang-ru-js/ext.axd?v=41064"></script>

    <meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge" />


Daniil Veriga

unread,
Sep 2, 2014, 8:04:08 AM9/2/14
to ext...@googlegroups.com
Используйте ResourcePlaceHolder.

<head runat="server">
    <title>Ext.NET v2 Example</title>

     <meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge" />

    <ext:ResourcePlaceHolder runat="server" Mode="Style" />
    <ext:ResourcePlaceHolder runat="server" Mode="ScriptFiles" />
</head>

pru...@yandex.ru

unread,
Sep 12, 2014, 12:04:36 AM9/12/14
to ext...@googlegroups.com


вторник, 2 сентября 2014 г., 18:04:08 UTC+6 пользователь Daniil написал:
Не помогло

 вот что написал  в _Layout.cshtml:


<?xml version="1.0"?>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
   
    <title>@ViewBag.Title</title>

    <meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge" />
    <ext:ResourcePlaceHolder runat="server" Mode="Style" />
    <ext:ResourcePlaceHolder runat="server" Mode="ScriptFiles" />


Результат:


<?xml version="1.0"?>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

    <link type="text/css" rel="stylesheet" href="/extjs/resources/ext_theme_classic/ext-theme-classic-all-embedded-css/ext.axd?v=41064" id="ext-theme" />
    <link type="text/css" rel="stylesheet" href="/extnet/resources/css/extnet-all-embedded-css/ext.axd?v=41064" id="extnet-styles" />
    <script type="text/javascript" src="/extjs/ext-all-js/ext.axd?v=41064"></script>
    <script type="text/javascript" src="/extnet/extnet-all-js/ext.axd?v=41064"></script>
    <script type="text/javascript" src="/extnet/locale/ext-lang-ru-js/ext.axd?v=41064"></script>
<title>Index</title>

pru...@yandex.ru

unread,
Sep 12, 2014, 12:35:58 AM9/12/14
to ext...@googlegroups.com


вторник, 2 сентября 2014 г., 17:29:21 UTC+6 пользователь pru...@yandex.ru написал:
Цитата из документации:

ResourcePlaceHolder Class


Simple Container Control to allow for custom placement of Scripts and Styles in the <head> of the Page by the ResourceManager. If the Page does not contain a <ext:ResourcePlaceHolder> control, the <script>'s and <style>'s will be added as the last items in the <head>. The ResourceContainer does not render any HTML to the Page.

Т.е. фактически и так должно работать, но почему то ExtNet свои записи в HEAD добавляет в начало


 

Daniil Veriga

unread,
Sep 12, 2014, 3:09:43 AM9/12/14
to ext...@googlegroups.com
Документация осталась не обновлённой после Ext.NET v1. Там так было.

В v2 вместо "last" должно быть "first". Поправил доки в SVN. Спасибо, что выцепили это.

Что касается MVC Razor, то там это должно выглядеть вот так:

@{
    var X = Html.X();
}

<!DOCTYPE html>
<html>
<head>
    <title>Ext.Net.MVC v2 Example</title> 
   
    <meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge" />
    @X.ResourcePlaceHolder(ResourceMode.ScriptFiles)
    @X.ResourcePlaceHolder(ResourceMode.Style)
</head>
<body>
    @X.ResourceManager()
   
</body>
</html>

--
Вы получили это сообщение, поскольку подписаны на группу "Ext.NET".
Чтобы отменить подписку на эту группу и больше не получать от нее сообщения, отправьте письмо на электронный адрес extnet+un...@googlegroups.com.
Чтобы настроить другие параметры, перейдите по ссылке https://groups.google.com/d/optout.

pru...@yandex.ru

unread,
Sep 16, 2014, 1:55:03 AM9/16/14
to ext...@googlegroups.com
Сделал так:

<?xml version="1.0"?>

@{
    var X = Html.X();
}
<!DOCTYPE html >

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>@ViewBag.Title</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta charset="utf-8"/>
    @X.ResourcePlaceHolder(ResourceMode.ScriptFiles)
    @X.ResourcePlaceHolder(ResourceMode.Style)  
 
Вот результат:

<?xml version="1.0"?>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

    <link type="text/css" rel="stylesheet" href="/extjs/resources/ext_theme_classic/ext-theme-classic-all-embedded-css/ext.axd?v=41064" id="ext-theme" />
    <link type="text/css" rel="stylesheet" href="/extnet/resources/css/extnet-all-embedded-css/ext.axd?v=41064" id="extnet-styles" />
    <script type="text/javascript" src="/extjs/ext-all-js/ext.axd?v=41064"></script>
    <script type="text/javascript" src="/extnet/extnet-all-js/ext.axd?v=41064"></script>
    <script type="text/javascript" src="/extnet/locale/ext-lang-ru-js/ext.axd?v=41064"></script>
<title>Index</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta charset="utf-8"/>

Таким образом не помогло.

А при использовании ResourceManager() вылетает ошибка:

Код:


<?xml version="1.0"?>

@{
    var X = Html.X();
}
<!DOCTYPE html >

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>@ViewBag.Title</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta charset="utf-8"/>
    @X.ResourcePlaceHolder(ResourceMode.ScriptFiles)
    @X.ResourcePlaceHolder(ResourceMode.Style)  

    .....

</head>
<body>
    @X.ResourceManager()
    @RenderBody()
</body>

вылетает ошибка:

Server Error in '/' Application.
--------------------------------------------------------------------------------


 Token is not unique
-------------------
ID = ext.net.global.scripts
TagName = anchor
Match = <#:anchor id='ext.net.global.scripts' />
 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Transformer.NET.TokenNotUniqueException: Token is not unique
-------------------
ID = ext.net.global.scripts
TagName = anchor
Match = <#:anchor id='ext.net.global.scripts' />


Source Error:




An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:





[TokenNotUniqueException: Token is not unique
-------------------
ID = ext.net.global.scripts
TagName = anchor
Match = <#:anchor id='ext.net.global.scripts' />
]
   Transformer.NET.Token.ParseAnchors() +532
   Transformer.NET.TextTransformer.Parse(List`1 tokensType, Dictionary`2 variables) +1088
   Transformer.NET.TextTransformer.Transform(List`1 tokensType, Dictionary`2 variables) +42
   Transformer.NET.TextTransformer.Transform(List`1 tokensType) +40
   Transformer.NET.TextTransformer.Transform() +56
   Ext.Net.ExtNetTransformer.Transform(String text) +225
   Ext.Net.InitScriptFilter.Transform() +52
   Ext.Net.InitScriptFilter.Flush() +79
   System.Web.HttpWriter.Filter(Boolean finalFiltering) +8875596
   System.Web.HttpResponse.FilterOutput() +119
   System.Web.CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +52
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
 

Daniil Veriga

unread,
Sep 16, 2014, 2:19:31 AM9/16/14
to ext...@googlegroups.com
Попробуйте, пожалуйста, в чистом новом проекте с самой простой Index.cshtml View. Работает ли так?

Что касается вашего случая, когда не работает. Можно глянуть на код View полностью?



pru...@yandex.ru

unread,
Sep 16, 2014, 2:46:10 AM9/16/14
to ext...@googlegroups.com

В коде Index.cshtml оказывается есть уже запись @(Html.X().ResourceManager()) что и вызывало ошибку дублирования ID.

pru...@yandex.ru

unread,
Sep 16, 2014, 5:20:49 AM9/16/14
to ext...@googlegroups.com
Проект я создал уже как год назад, и постепенно веду его разработку. Поэтому у меня возникли трудности при создании тестового проекта, забыл что да как делал, после создания проекта и загрузки нугетом последней версии ExtNet появляется ошибка:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper<dynamic>' does not contain a definition for 'X' and no extension method 'X' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<dynamic>' could be found (are you missing a using directive or an assembly reference?)

Source Error:

 

Line 1:  @{
Line 2:      var X = Html.X();
Line 3:  }
Line 4:  <!DOCTYPE html>

 


и еще в моей рабочей версии проекта в представлении в первых строках указано :
@using Ext.Net;
@using Ext.Net.MVC;

в тестовой версии пришлось сделать так:
@using Ext.Net;
@*@using Ext.Net.MVC;*@

Иначе возникает ошибка:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0234: The type or namespace name 'MVC' does not exist in the namespace 'Ext.Net' (are you missing an assembly reference?)

Source Error:

 

Line 1:  @using Ext.Net;с
Line 2:  @using Ext.Net.MVC;
Line 3: 
Line 4:  @{
 

Source File: c:\Users\akchurin.ae\Documents\Visual Studio 2010\Projects\TestExt\TestExt\Views\Test\Index.cshtml    Line: 2

Версия  ExtNet моего проекта Ext.NET.MVC.Pro.2.3.1
Версия ExtNet тестового проекта Ext.NET.2.5.2

pru...@yandex.ru

unread,
Sep 16, 2014, 6:25:33 AM9/16/14
to ext...@googlegroups.com

Все решил:

из Index.cshtml надо убрать

@*@using Ext.Net;
@using Ext.Net.MVC;*@

 
а также:
@*@(Html.X().ResourceManager())*@

в __Layout.cshtml необходимо добавить:
<body>
     @X.ResourceManager()
    @RenderBody()
</body>

Спасибо за советы

Reply all
Reply to author
Forward
0 new messages