ms reportviewer not show data on host server - reportviewer2008

I have created an Asp.net Project, I use MS Reportviewer for Reports of my project. When I place this project in my IIS by creating new Application in my main project. In it my reports Shows Correct but when I place this project on shared host by creating Virtual directory under my main project then No Data shows in it and the following error comes.
**Not Found**
The requested document was not found on this server.
In my webpage I call Report as Shown below
<div>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
Font-Size="8pt" Height="575px" Width="100%">
<localreport reportpath="Reports\rptChartofAccount.rdlc">
<datasources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="trialBalnace_vwBalanceSheet" />
</datasources>
</localreport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetData" TypeName="AmsWeb.trialBalnaceTableAdapters.vwBalanceSheetTableAdapter" >
</asp:ObjectDataSource>
</div>
and in my Code Behind
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ObjectDataSource1.SelectParameters.Add("brid", Session("BrId"))
Dim Param(0) As ReportParameter
Param(0) =New ReportParameter("BrName", Session("BrName").ToString)
ReportViewer1.LocalReport.SetParameters(Param)
ReportViewer1.LocalReport.Refresh()
End Sub
for ms reportviewer web.config file is as follows
<httpHandlers>
<remove path="*.asmx" verb="*"/>
----------
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>
</httpHandlers>
<httpModules>
and Assembly added as following
<assemblies>
<clear/>
<add assembly="*"/>
<add assembly="Microsoft.ReportViewer.WinForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</assemblies>
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</buildProviders>

Related

Sitecore 7.5 to other MVC Solution

I am trying to add sitecore to an existing solution where we already have an MVC Application.Now after adding Sitecore,I will make sitecore as start up project and add the reference of existing MVC Application as a reference to Sitecore MVC Application.
Since the existing application was using 4.5.1 and MVC 5.2.3,I am also using the same for my sitecore application.But the existing MVC application is using below:
1. System.Web.Http (Version:5.2.3.0)
2. System.Web.Http.WebHost (Version:5.2.3.0)
3. System.Net.Http.Formatting (Version:5.2.3.0)
So can I use the same for Sitecore?.If yes then I will have to Modify Web Config
From:
<compilation defaultLanguage="c#" debug="false" targetFramework="4.5.1">
<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.Helpers, Version=3.0.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Http, Version=5.1.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Http.WebHost, Version=5.1.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Net.Http.Formatting, Version=5.1.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
To:
<compilation defaultLanguage="c#" debug="false" targetFramework="4.5.1">
<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.Helpers, Version=3.0.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Http, Version=5.2.3.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Http.WebHost, Version=5.2.3.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
Is this change fine?.Please suggest.
Instead of adding Sitecore to your solution you should probably look at it the other way around I.e getting your Mvc application to work in Sitecore.
You shouldn't really change the assembly versions Sitecore is using and you should try to get your Mvc application to work with Sitecore. You can't 100% guarantee that Sitecore will work using higher or lower versions of assemblies that it needs. Whereas with your Mvc solution (I'm assuming you have the source code) you can always try to modify this to work with Sitecore.
Verified with sitecore support and they confirmed that all the above changes are fine.

Server Error in '/' Application. Error in vb.net

After hosting when i run the application am getting error like above. but that application worked on local machine with out any error.
web config file
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="testConnectionString" connectionString="server=10.103.1.166;User Id=root;database=test;password=test123" providerName="MySql.Data.MySqlClient"/>
<!--<add name="testConnectionString" connectionString="server=10.103.200.138;User Id=root;database=test;password=test123" providerName="MySql.Data.MySqlClient"/>-->
<!--'LDAP://servername/ou=ouname,dc=domain,dc=com-->
<add name="ADConnection" connectionString="LDAP://sunbs.in:389/ou=sunbs,DC=sunbs,DC=in"/>
<!--<add name="TestDomain1ConnectionString" connectionString="LDAP://testdomain1.test.com/CN=Users,DC=testdomain1,DC=test,DC=com" />-->
</connectionStrings>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
<assemblies>
<add assembly="MySql.Data, Version=6.5.4.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.DirectoryServices.AccountManagement, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation>
<!--<membership >
<providers >
<add name="NetForgeMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="ADConnection" connectionUsername="sbsldap" connectionPassword="sbs#123" />
</providers>
</membership>-->
<membership defaultProvider="MyADMembershipProvider">
<providers>
<add name="MyADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ADConnection" attributeMapUsername="sAMAccountName"/>
</providers>
</membership>
<customErrors mode="Off "></customErrors>
<!--<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>-->
</system.web>
</configuration>
How can I correct the error?
error description
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

How to develop a simple ASP.NET MVC project without Visual Studio

I have been able to develop a simple asp.net project without vs. Can someone help me doing the same for a asp.net mvc 3. Starting from getting the ASP.NET MVC 3 framework. It seems that we can't download anymore the assemblies. Is it possible to have the project compiled on the fly ( I mean without compiling the my web application but letting IIS doing so , it is possible to achieve this with the regular asp.net so I assume it could be possible with the MVC framework)
Thx
Dave
Sure, it's pretty easy, only a couple of steps after you install ASP.NET MVC 3.
Fire notepad.exe and create a HomeController.cs file (Of course if you don't want to use notepad you could also do this by using the copy con HomeController.cs command on the command prompt, this way you will be closer to the metal):
namespace MyApplication
{
using System.Web.Mvc;
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
}
}
Compile on the command prompt (adjust the folders to match yours)
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /t:library /out:MyApplication.dll /r:"C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll" HomeController.cs
Create a folder c:\MyApplication
Create a folder c:\MyApplication\bin and copy MyApplication.dll to this bin folder.
Inside c:\MyApplication\web.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="webpages:Version" value="1.0.0.0"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<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"/>
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Inside c:\MyApplication\Views\web.config:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.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=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
Inside c:\MyApplication\Global.asax:
<%# Application Language="C#" %>
<%# Import Namespace="System.Web.Mvc" %>
<%# Import Namespace="System.Web.Routing" %>
<script runat="server">
static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
}
</script>
Inside c:\MyApplication\Views\Home\Index.cshtml:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
Hello Word
</body>
</html>
Now you have all the necessary files for an ASP.NET MVC 3 application. The final step is to host it on a web server and run it.
Conclusion: unless you are suffering from some severe brain damage you will never do this and simply download Visual Studio 2010 Express and start developping ASP.NET MVC 3 applications by following the tutorials on the ASP.NET MVC web site.
Could you give a reason you don't want to use visual studio? There are free versions that are quite capable as IDEs.
If you would prefer to learn in a much more text editor experience you can also use Microsoft WebMatrix to create them on your local computer.
The easiest way to install Webmatrix or Visual Studio Web Developer Express is probably using the Web Platform Installer.

Need razor view engine auto-complete to work in a class library?

We have a modular architecture where we have some views (cshtml) files in a separate project (class library). How can we get the syntax highlighting and autocomplete to work when the project isn't an MVC project?
Please note that the class library has controllers, views, models etc. It just doesn't have the web.config, global.asax, etc that a normal mvc project would have.
The intellisense works for everything but the so important model:
With MVC3 RTM, if you hover over the Model, you can now get a better error message:
C:\...\Index.cshtml: ASP.NET runtime
error: There is no build provider
registered for the extension
'.cshtml'. You can register one in the
<compilation><buildProviders>
section in the machine.config or
web.config. Make sure is has a
BuildProviderAppliesToAttribute
attribute which includes the value
'Web' or 'All'.
So I added this:
<compilation>
<assemblies>
<add assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
<buildProviders>
<add
extension=".cshtml"
type="System.Web.WebPages.Razor.RazorBuildProvider, System.Web.WebPages.Razor"/>
</buildProviders>
</compilation>
Then after adding the build provider, this error message appears:
C:\...\Index.cshtml: ASP.NET runtime
error: Could not load file or assembly
'System.Web.WebPages.Razor' or one of
its dependencies. The system cannot
find the file specified.
(C:\...\machine.config line 259)
The webconfig from this post will work. I've copied it below (for posterity):
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.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=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>
<system.web>
<compilation targetFramework="4.0">
<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=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>
</compilation>
</system.web>
</configuration>
For Visual Studio 2012/ASP.NET MVC 4, you need to update the assembly versions and add <add key="webpages:Version" value="2.0.0.0" /> to appSettings. Here's what my Web.config looks like:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.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=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
</appSettings>
<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=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
</system.web>
</configuration>
I have followed Jammer's suggestion and am documenting what I believe is the minimal set of actions to get a project suitable for serving as an ASP.NET MVC4 class library project. This was done in Visual Studio 2012 Update 4, and was targeting VB.Net. I may later include documentation for doing something similar in Visual Studio 2013 if I get a chance. Here are the actions I took:
Create a new blank MVC4 project with a separate directory for the solution (so you can clearly see that the packages directory with updated versions of reference files is part of the project).
Add a dummy controller, view and model to test it (which entailed copying the output DLL and view to another web application after building the class library).
Delete the following files from the project:
The whole App_Start folder
The whole App_Data folder and any other empty folders (my Mercurial history didn't make this visible so I'm going from memory).
Global.asax
Global.asax.vb
The Web.config file in the root and the dependent Web.Debug.config and Web.Release.config files. (Do not delete Web.config from the Views folder.)
Delete the following sections from the Web.config file in the Views folder:
appSettings
system.web
system.webServer
You may also delete lines <add namespace="System.Web.Mvc.Ajax" /> and <add namespace="System.Web.Routing" />
Remove the following references from the project (* starred references were version-specific references that went into the packages directory and have Copy Local and Specific Version set to True).
System.Web.Entity
System.Web.ApplicationServices
System.ComponentModel.DataAnnotations
System.Data.DataSetExtensions
System.Web.Extensions
System.Web.Extensions.Design
System.Xml.Linq
System.Web.Abstractions
System.Web.Routing
System.Configuration
System.Web.Services
System.EnterpriseServices
Microsoft.Web.Infrastructure (1.0.0.0) *
Microsoft.Web.Mvc.FixedDisplayModes (1.0.0) *
Newtonsoft.Json (4.5.11) *
System.Net.Http (2.0.20710.0) *
System.Net.Http.Formatting (4.0.20710.0) *
System.Net.Http.WebRequest (2.0.20710.0) *
System.Web.Helpers (2.0.20710.0) *
System.Web.Http (4.0.20710.0) *
System.Web.Http.WebHost (4.0.20710.0) *
Remove the following project-wide Imports from the project settings:
System.Xml.Linq
System.Collections.Specialized
System.Configuration
System.Web.Caching
System.Web.Mvc.Ajax
System.Web.Routing
System.Web.SessionState
System.Web.Security
System.Web.Profile
System.Web.UI
System.Web.UI.WebControls
System.Web.UI.WebControls.WebParts
System.Web.UI.HtmlControls
Remove the following from packages.config:
<package id="Microsoft.AspNet.Mvc.FixedDisplayModes" version="1.0.0" targetFramework="net40" />
<package id="Microsoft.AspNet.WebApi" version="4.0.20710.0" targetFramework="net40" />
<package id="Microsoft.AspNet.WebApi.Client" version="4.0.20710.0" targetFramework="net40" />
<package id="Microsoft.AspNet.WebApi.Core" version="4.0.20710.0" targetFramework="net40" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="4.0.20710.0" targetFramework="net40" />
<package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net40" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net40" />
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" />
Delete the following sub-directories from the packages folder:
Microsoft.AspNet.Mvc.FixedDisplayModes.1.0.0
Microsoft.AspNet.WebApi.4.0.20710.0
Microsoft.AspNet.WebApi.Client.4.0.20710.0
Microsoft.AspNet.WebApi.Core.4.0.20710.0
Microsoft.AspNet.WebApi.WebHost.4.0.20710.0
Microsoft.Net.Http.2.0.20710.0
Microsoft.Web.Infrastructure.1.0.0.0
Newtonsoft.Json.4.5.11
This leaves me with the following:
A VB.Net class library project targeting .NET Framework 4 (although I had intended this to be 4.5 - I think either works).
The following non-default .NET references (starred references must have Copy Local and Specific Version set to True):
System.Web
packages\Microsoft.AspNet.Mvc.4.0.20710.0\lib\net40\System.Web.Mvc.dll *
packages\Microsoft.AspNet.Razor.2.0.20715.0\lib\net40\System.Web.Razor.dll *
packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.dll *
packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Deployment.dll *
packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Razor.dll *
The following non-default imports:
System.Web
System.Web.Mvc
System.Web.Mvc.Html
The following project files/structure:
Controllers folder containing CustomUIController.vb
Models folder containing CustomUIModel.vb
Views folder containing CustomUI folder, containing Index.vbhtml
Web.config file in the Views folder. See below for content.
packages.config file in the root of the project. See below for content.
The contents of my files are as follows:
Web.config
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.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=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Html" />
</namespaces>
</pages>
</system.web.webPages.razor>
</configuration>
packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" targetFramework="net40" />
<package id="Microsoft.AspNet.Razor" version="2.0.20715.0" targetFramework="net40" />
<package id="Microsoft.AspNet.WebPages" version="2.0.20710.0" targetFramework="net40" />
</packages>
CustomUIController.vb
Imports System.Web.Mvc
Public Class CustomUIController
Inherits Controller
Public Function Index() As ActionResult
Return View()
End Function
End Class
CustomUIModel.vb
Public Class CustomUIModel
Public Property Name As String
Public Property Value As Decimal
End Class
Index.vbhtml
#ModelType CustomTemplate.CustomUIModel
#Html.LabelFor(Function(m) m.Name)
At this point I am able to work with Intellisense assisting me in the .vbhtml views and the .vb classes, build the project, then copy just the views to the primary application's deployed Views folder (in the appropriate sub-directory), and the project's primary output DLL to the primary application's deployed bin directory (the dependent DLL files are already there).
Edit:
After following the process on another system to validate it and how it works for .NET 4.5 and VS 2013, I have noticed the following:
I think I neglected to mention that the reference to System.Web.DynamicData can be removed.
In VS 2013 and/or .NET 4.5, some versions change:
packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll
packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll
packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.dll
packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Deployment.dll
packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll
I don't know if I made a strong enough point of it above, but the references to private (Copy Local) DLLs do have to be set to Copy Local, and/or do have to use the version provided in the packages folder when creating a project from the MVC4 template. I don't know why, but the .NET standard versions (non-private) don't seem to work, as far as Intellisense is concerned at least.
Best way to check if things are still "OK" as far as the IDE is concerned is to close the solution, delete the bin and obj folders in the custom project's output, re-load the solution, put the cursor on LabelFor in the Index.vbhtml file, and press the F12 key to see if it takes you to the Object Browser.
Because of the new versions, the packages file is different:
Packages.config
<packages>
<package id="Microsoft.AspNet.Mvc" version="4.0.30506.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="2.0.30506.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="2.0.30506.0" targetFramework="net45" />
</packages>
Alright, this is a longshot, but I ran across the same problem. Are you using JetBrains Resharper?
Resharper overrides VS's intellisense engine but it doesn't understand Razor syntax. You simply have to tell VS to rely on its own intellisense rather than Resharper's.
In VS2010, go Resharper - Options - Intellisense - General. Then check the Visual Studio radio button.
Worked great for me.
None of the solutions I could find online or on SO fixed this for me.
May seem like a sledgehammer to crack a nut but I created an MVC 4 application project instead of a class library and ripped out everything I didn't need. Intellisense and #model working fine.

Why is my MVC site asking for logon?

I have created a ASP.NET MVC app and changed from the dev server to the local IIS
server by clicking on Create Virtual Directory and also changing managed pipeline mode
to integrated.
But now when I run the app it shows the logon page.
Why, this is my web.config???
<?xml version="1.0"?>
<configuration>
<system.web>
<httpHandlers>
<add path="*" verb="*"
type="System.Web.HttpNotFoundHandler"/>
</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=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
</handlers>
</system.webServer>
</configuration>
That looks like the Web.Config inside the Views folder. You should check the one in the root of your site.

Resources