Module Development help with orchard 1.8 VS 2013

Topics: Core, Customizing Orchard, General, Troubleshooting, Writing modules
Oct 14, 2014 at 11:17 AM
__Hey Guy,

i had working with orchard modules develepment everythig going well until view and templete secsion in my view folder view/EditorTemplates/Parst/Service.cshtml
"@model Service.Models.ServicePart" @model razor section and @Html not detected
i had create web.config in my view folder and i make other web.config in root of module folder that's same of Orchard.web config i was searching and i found the same problems with other developers how i can solve this i'm using Orchard 1.8
here is my Web.Config of View
<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="webpages:Enabled" value="false" />
  </appSettings>
  <system.web>
    <httpHandlers>
    </httpHandlers>
 
    <!--
        Enabling request validation in view pages would cause validation to occur
        after the input has already been processed by the controller. By default
        MVC performs request validation before a controller processes the input.
        To change this behavior apply the ValidateInputAttribute to a
        controller or action.
    -->
    <pages
        validateRequest="false"
        pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35, processorArchitecture=MSIL"
        pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35, processorArchitecture=MSIL"
        userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35, processorArchitecture=MSIL">
      <controls>
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35, processorArchitecture=MSIL" namespace="System.Web.Mvc" tagPrefix="mvc" />
      </controls>
    </pages>
  </system.web>
 
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <handlers>
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
and here is Web.config or my root module folder project
<?xml version="1.0"?>
<configuration>

  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <remove name="host" />
      <remove name="pages" />
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>

  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <pages pageBaseType="Orchard.Mvc.ViewEngines.Razor.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
        <add namespace="System.Linq"/>
        <add namespace="System.Collections.Generic"/>
        <add namespace="Orchard.Mvc.Html"/>
      </namespaces>
    </pages>
  </system.web.webPages.razor>

  <system.web>
    <compilation targetFramework="4.5">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </assemblies>
    </compilation>
  </system.web>

</configuration>
Oct 14, 2014 at 11:52 AM
Edited Oct 14, 2014 at 11:53 AM
I don't get the question, however to avoid troubles with web.config you should let Code Generation handle it for you. Run bin/Orchard.exe and type in commands
> feature enable Orchard.CodeGeneration
> codegen module MyCompany.MyModule
For more information http://docs.orchardproject.net/Documentation/Command-line-scaffolding
Oct 14, 2014 at 2:23 PM
Edited Oct 14, 2014 at 2:26 PM
thank you for your reply my problem is i can't get razor section in my code of view

name @model does not exist in the current context

here is my code of my view template
@using System.Web.Mvc.Html
@model Service.Models.ServicePart

<fieldset>
    <label class="sub" for="service_name">@T("service_name")</label><br />
    @Html.TextBoxFor(m => m.service_name, new { @class = "text" })<br />
</fieldset>
Oct 14, 2014 at 5:29 PM
You mean you lost the Razor's intellisense. That happened to me a lot.
What always helps is to codegen your module like Xeevis suggested. If you already have programmed stuff then try to change the project's target .Net framework and/or the web.config
Oct 16, 2014 at 2:26 PM
thanks for replies guys,
actually i generat my module by codegen using orchard.exe and also i was trying to change my web.config in view and root of my module project folder .. right now i still get the red lines in viusal studio 2013 that's i lost the Razor's intellisense in my code scope but the result when i'm complie my project it's show the HTML lable i used them by razor elements here
@model Service.Models.ServicePart

<fieldset>
    <label class="sub" for="service_name">@T("service_name")</label><br />
    @Html.TextBoxFor(m => m.service_name, new { @class = "text" })<br />
</fieldset>
actually i don't know what's happened inside my project until this step :/
Developer
Oct 16, 2014 at 5:02 PM
Use this: https://visualstudiogallery.msdn.microsoft.com/47bded90-80d8-42af-bc35-4736fdd8cd13

And make sure all your projects are the same .NET Version.
Oct 17, 2014 at 9:39 AM
Edited Oct 17, 2014 at 9:44 AM
i've tried this tools and i migrate all my projects to .NET 4.5 Version when i try to open my module from Dashboard i get this error and @model still not detected again
Server Error in '/OrchardLocal' 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: CS0103: The name 'model ' does not exist in the current context

Source Error:

Line 1: @model SampleTitle.Models.SampleTitlePart
Line 2:
Line 3: <fieldset>


Show Detailed Compiler Output:
C:\Program Files (x86)\IIS Express> "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe"
Microsoft (R) Visual C# Compiler version 4.0.30319.34209 for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.
Oct 17, 2014 at 9:51 AM
Actually guy i can't understand this problem correctrly for fetching razor's intellisense with web.config
i just was trying to reload my modules files again and it's working but there is still red underlines for my razor's code

Thanks in advance for you all