Classic asp and integrated mode - asp.net-mvc

Is it possible to run classic asp page in integrated mode of IIS7?
I need it for integrating our legacy asp application with new asp.net mvc application.
I have seen seen several examples with web.config:
<add name="classic-asp"
path="*.asp"
verb="*"
type="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll"
resourceType="File"
preCondition="integratedMode" />
But it doesn't work for me.
Thanks,

You can not run Classic ASP(VBScript) and ASP.NET/MVC using same application pool.
You will have to create separate folders for each part or at least one as virtual folder for classic asp and assign to it application pool as non-managed code.
Main reason for this because as you clearly stated in your question - both using different ISAPI filters: c:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_filter.dll for MVC or NET part and it will not handle Classic asp as you expect it to.
For that you need C:\Windows\System32\inetsrv\asp.dll

Related

Is it possible to deploy WCF and MVC applications to 1 application?

I have WCF application and MVC application in 1 solution. When I deploy projects with WCF, I always deployed them like 2 sites. Firstly, I deployed WCF application to IIS, then MVC application and use WCF's endpoint address.
My question is that, is it possible to deploy MVC and WCF applications together, not like 2 separate site? WCF runs inside ASP application. And in IIS we have 1 site.
Yes it is possible. Merge WCF application & MVC application together into a single project. If your WCF project contains too many classes you can move them into a class library.
But you must move following items into web application project:
Move .svc file into MVC project, this file does all the magic to
host your WCF service into IIS.
Move System.Service Model section of WCF application into MVC
project.
I done this.. Works well in local...
But When you host it in an IIS or web deploying
add this code in webconfig
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

WCF 4.0 & Sync Framework 2.0 & Entity Framework 4.0 & ASP.NET MVC 2.0 & auto generated code

I have to use Sync Framework 2.0 in our WPF app that will contain SQL Compact 3.5 and will synchronize with SQL Server 2008.
I followed this video : http://download.microsoft.com/download/6/7/3/6730f0e7-a649-4656-96ab-150c7501a583/IntroToSyncServicesADODetNet_HighQuality.wmv.
But instead DataSet I've used EntityFramework 4.0 and C#.
I'm very interested in code auto generation by adding Local Database Cache file with extension sync. It is great, and I can modify code in my partial class to change base functionality.
Everything works grate when I have code for client and server place in WPF application.
Everything works grate when I use WCF Class Library that contains server synchronization logic.
But... In the following example they show us how to run solution and host WCF in local "WCF Host" only on my computer.
The first question is:
"How can I create instance of class from WCF Class Library that contains all server synchronization logic and then host it and expose in ASP.NET MVC 2.0 application."
The most important thing is to keep this *.sync files and don't write all the code manually it gives me the option to automatically update this code when database schema would change.
The second question is:
"How can I configure endpoints and behaviors for this instance of WCF Class Library in my web.config when it has its on app.config in class library?..."
Unfortunately wizard for *.sync files only sees local WPF application, or WCF Class Library, I can't choose directly ASP.NET MVC 2.0 (it would be great) to generate class for synchronization in web app.
I would be very pleased to see working example.
Regards,
Daniel Skowroński
Solution to create WCF Class Library instance with synchronization logic hosted in ASP.NET MVC 2.0:
follow http://download.microsoft.com/download/6/7/3/6730f0e7-a649-4656-96ab-150c7501a583/IntroToSyncServicesADODetNet_HighQuality.wmv to create WCF Class Library
create ASP.NET MVC 2.0 App and add WCF Service
delete C# file *.cs behind *.svc
add Project Referece from ASP.NET projet to WCF Class Library
edit your *.svc file in ASP.NET
here you will see something like:
<%# ServiceHost Language="C#" Debug="true" Service="namespace-assembly.class" CodeBehind="filename.svc.cs" %>
where Service is Factory method that will create instance of "namespace-assembly.class" so, you have to change this to "wcf_librrary_namespace-assembly.****DataCacheSyncService" and CodeBehind to "wcf_librrary_namespace-assembly.filename.cs"
next modify wcf instance in WCF Class Library that will enable hosting it with the same credentials as asp.net app, simply add : [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] attribute
next configure web.config:
<service name="asp.net-namespace.wcf_service_name" behaviorConfiguration="service_nameBehavior">
<host>
<baseAddresses>
<add baseAddress="http://ipaddres/asp.net-app-name/service-name.svc" />
</baseAddresses>
</host>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="" binding="basicHttpBinding" contract="wcf_librrary_namespace assembly.I****DataCacheSyncContract" />
</service>
<behavior name="service_nameBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
add also
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
below
<system.serviceModel>
now simply publish it to your server and create ASP.NET app
now add Service Reference to your Client Application
here we have problem that when you will execute:
**DataCacheSyncAgent syncAgent = new **DataCacheSyncAgent(new **DataCacheSyncContractClient());
Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();
You will probably get Exception: “Cannot convert type ** to Microsoft.Synchronization.Data.SyncGroupMetadata, One solution to resolve this issue for now that I’ve found is to expand your service reference and b CTR+H rename all “asp-net-assembly-SyncGroupMetadata” and other similar files to “Microsoft.Synchronization.Data.SyncGroupMetadata” etc.
Now synchronization should start
HTH
Regards,
Daniel Skowroński

ASP.NET MVC application when deployed to IIS 7 in integrated mode using NHibernate data will not load

We have built an ASP.NET MVC application which utilizes NHibernate, the MVCContrib version of StructureMap, and an onion architecture as outlined by Jeffery Palermo in ASP.NET MVC in Action. This application works well when running locally from Visual Studio 2008.
The Index action on our Home controller loads a view which immediately pulls data from the database utilizing the tools as outlined above. When running on IIS 6 or in Classic Mode on IIS 7 this section of the page loads data. Of course in both of these modes 404 File Not Found errors abound. Unfortunately, when running under IIS 7 Integrated mode no data loads and a simple error message Sorry, an error occurred while processing your request is displayed where the data should be rendered. Other page elements like CSS and images are loaded. Is there an IIS 7 setting we have missed? Is there something I should be looking for in the web.config?
Edit
Changed the customErrors mode setting in the web.config to off. Not sure if this is an ASP.NET MVC or IIS 7 thing but am now seeing a standard error screen on the pages that used to display the sorry error message. I am getting an unhandled exception of NullReferenceException: Object reference not set to an instance of an object. Looking at the stack this appears to be occurring when trying to get data. What would be the difference between IIS 7 Classic Mode / IIS 6 and IIS 7 Integrated mode that would cause this issue?
Edit 2
After some Googling this morning came across a post MVC + Sharp + IIS7 + NHibernate which seems like it would solve the problem. The post is from June '09 has something changed in the time since then that I don't have to drop back to classic mode?
After thinking about what was going on and realizing that issue probably had something to do with NHibernate I refined some of my Google searches and found a post HttpModule and HttpHandler sections in IIS 7 web.config files. This reminded me that NHibernate requires an httpModules entry.
<system.web>
<httpModules>
<add name="StartupModule" type="Infrastructure.NHibernateModule,
Infrastructure, Version=1.0.0.0, Culture=neutral"/>
</httpModules>
</system.web>
Because of the way that IIS 7 in integrated mode works I had to add the following to the modules section of system.webServer.
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<add name="StartupModule" type="Infrastructure.NHibernateModule,
Infrastructure, Version=1.0.0.0, Culture=neutral" />
</modules>
</system.webServer>
Because I needed to have both the modules work in both system.web and system.webServer I added the validation section to the system.webServer.

"Resource not found" error while accessing elmah.axd in ASP.NET MVC project

My ASP.NET MVC application is within a folder called Stuff within IIS 6.0 webroot folder. So I access my pages as http://localhost/Stuff/Posts. I had EMLAH working while I was using the in-built webserver of Visual Studio. Now when I access http://localhost/Stuff/elmah.axd, I get resource not found error. Can anyone point my mistake here! Here is config file entry,
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/> //Handler
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/> //Module
Working with IIS7 I found I needed both sections of the web.config populated (system.web AND system.webServer) - see Elmah not working with asp.net site.
Perhaps this is related.
Have you added an ignore *.axd routes in global.asax?
For Elmah, we need to differentiate between two things:
First the http modules doing all the work of error logging, emailing...etc.
Second, the http handlers, displaying the error log page and other pages (rss...etc.)
I was having the same problem of 404 resource not found because I have a weird setup!
on my development machine, (windows 7, iis 7 ) elmah was working like a charm because the application pool was working in the integrated pipeline mode. In the production machine, however, the application was using the managed pipeline and I tried all my best to make elmah work but it was all useless...
I then got the idea of displaying the UI (error log page, rss, error detail,...) using regular aspx pages.
I downloaded the source code, made some changes (sorry Atif, I was forced to do this because I needed the quickest solution) and then in my application , I created a folder under which I created regular aspx pages which inherits from Elmah defined pages.
The page only contains one line (ex: for the detail page: <%# Page Language="C#" Inherits ="Elmah.ErrorDetailPage"%>)
Now, I was able to run Elmah regardless of IIS 6/7 and it is working like a charm.. and It saved me from a big headache of correctly configuring http handlers and troubleshooting its work! additionally, configuring security is much simpler!
I don't know if the community is interested in this solution (If so, I am ready to post my full changes).
Hope that this gives you an idea on how to solve the problem in an alternative way (and if you need the modified dll with complete instructions on how to use it, just tell me!)
In the application pool settings in IIS set Managed Pipelin Mode to Classic if you don't want to change code or the web.config file. Your axd.s will then work as before.
Can you post the rest of your web.config?
Or, if you're comfortable enough, can you just ensure that the httpHandlers and httpModules (NOT handlers and modules) sections are filled in properly in the web.config?

ASP.NET MVC Application in Sharepoint 2007 virtual directory

I have MOSS 2007 installed at lets say http://localhost:4999/ and I want to have my custom ASP.NET MVC (1.0) application at http://localhost:4999/mvcapp/ - logic dictates that, in IIS, i should create a new application virtual directory under my MOSS site and point it at my custom MVC app.
I've done this and it works for executing my controllers etc, however, none of my /Content content is being returned! All referenced images, javascript and css aren't retrieved.
If I put this app into it's own site, or a virtual application within a non-sharepoint site, this works fine and pulls down the images, js and css as normal.
Note - I'm creating a new application in IIS, not just a virtual directory and I have no requirement for integrating with sharepoint, I just want it to have the same domain and port number.
Any ideas?
Cheers
Tony
** EDIT **
To clarify - the URL's that are being generated aren't the issue - they are correct and are being generated in the same way as they would be if this wasn't hosted under sharepoint. IE: /mvcapp/Content/Scripts/jquery.js etc.
** EDIT 2 **
More clarification - the MVC app has it's own web.config file - but it appears that when using a virtual directory withn a sharepoint site, many of the handler mappings still get pushed up to the child site (Note: This is a virtual directory configured as a seperate application not just a virtual directory).
Whilst I don't want or need SharePoint integration, I need my MVC app to come from the same domain and port to overcome some cross domain issues (a lot of MVC content is iframed into sharepoint in various ways). So sharepoint would be at http://site and my app at http://site/mvc
I would keep them on separate web sites (MVC and SharePoint that is). You could create a new website entirely for your MVC app, and then through IIS, right click your MVC web site, edit bindings, and redirect the traffic from your MVC website to URL you want.
I set up a couple of WebForms apps to run in much the same way you say that you want: a separate virtual application with its own web.config, etc. I had to tweak the web.config to make it work, though. My app uses things like session state and view state, but I reckon those aren't applicable to your MVC app. As I look at my web.confing, I think this section might be applicable for what you're trying to do:
<location>
<system.web>
<xhtmlConformance mode="Legacy" />
<trust level="Full" />
<httpModules>
<remove name="PublishingHttpModule" />
</httpModules>
</system.web>
</location>
Hope that helps. I also have an <authorization> section in there, but it wasn't necessary to make the app work.
Look at the following:
Configuring Specific Files and Subdirectories (MSDN)
Disabling Configuration Inheritance For ASP.NET Child Applications (Blog)
HTH

Resources