This project is read-only.

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"?>
    <add key="webpages:Enabled" value="false" />
        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.
        pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35, processorArchitecture=MSIL"
        pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35, processorArchitecture=MSIL"
        userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35, processorArchitecture=MSIL">
        <add assembly="System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35, processorArchitecture=MSIL" namespace="System.Web.Mvc" tagPrefix="mvc" />
    <validation validateIntegratedModeConfiguration="false"/>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="" newVersion="" />
and here is Web.config or my root module folder project
<?xml version="1.0"?>

    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=, 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=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />

    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <pages pageBaseType="Orchard.Mvc.ViewEngines.Razor.WebViewPage">
        <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"/>

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

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
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

    <label class="sub" for="service_name">@T("service_name")</label><br />
    @Html.TextBoxFor(m => m.service_name, new { @class = "text" })<br />
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

    <label class="sub" for="service_name">@T("service_name")</label><br />
    @Html.TextBoxFor(m => m.service_name, new { @class = "text" })<br />
actually i don't know what's happened inside my project until this step :/
Oct 16, 2014 at 5:02 PM
Use this:

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