Deploying Castle Monorail on Windows Server 2003 - asp.net

I'm deploying a castle monorail web application to Windows Server 2003.
I've already set the httphandler mapping in web.config as follows :
<httpHandlers>
<add verb="*" path="*.castle" type="Castle.MonoRail.Framework.MonoRailHttpHandlerFactory, Castle.MonoRail.Framework" />
</httpHandlers>
<system.webServer>
<handlers>
<add name="castle page" path="*.castle" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
</handlers>
</system.webServer>
But whenever I tried to access http://localhost/app/Home/Index.castle the web server always returns HTTP 404 Not Found. It looks like the mapping is not handled by ASP.NET engine, like I've been missing a step or two in the configuration. Any solution?

Because you are using IIS 6.0 the <system.webServer> section is ignored and you need to associate the .castle extension with the ASP.NET ISAPI filter in the IIS control panel.
Phil Haack blogged about how to achieve this with ASP.NET MVC and the .mvc extension. For you this would be the .castle extension:

Related

ASP.NET httpHandlers & handlers

I am confused about httpHandlers in system.web and handlers in system.webServer. What is the difference between these two configuration? And how and when to use them?
Actually another question is for modules as well: httpModules in system.web and modules in system.webServer
The system.webServer section in the Web.config file specifies settings for IIS 7.0 that are applied to the Web application. The system.WebServer is a child of the configuration section. For more information, see IIS 7.0: system.webServer Section Group (IIS Settings Schema).
and <system.web> specifies the root element for the ASP.NET configuration section and contains configuration elements that configure ASP.NET Web applications and control how the applications behave. httpHandlers & handlers are same.
To register an HTTP handler for IIS 6.0 use should:
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="SampleHandler.new"
type="SampleHandler, SampleHandlerAssembly" />
</httpHandlers>
</system.web>
</configuration>
To register an HTTP handler for IIS 7.0 use should:
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="SampleHandler.new"
type="SampleHandler, SampleHandlerAssembly" />
</httpHandlers>
</system.web>
<system.webServer>
<add name=SampleHandler" verb="*" path="SampleHandler.new"
Modules="IsapiModule"
scriptProcessor="FrameworkPath\aspnet_isapi.dll"
resourceType="File" />
</system.webServer>
</configuration>
Read more Here
<system.web> is the configuration section for asp.net, traditionally this is where you would define your httpHandlers and httpModules.
With the introduction of IIS 7 (2007) the web server and asp.net got much more integrated and a completely new IIS configuration system was introduced.
As part of this the location for handler and module definitions was moved to <system.webServer>
If you are still using IIS6 (stop it) or use classic pipeline mode in IIS7+ you need to have your definitions under <system.web>, if you are using integrated pipeline mode in IIS7+ put them under <system.webServer>. You should not have them in both sections.

Set handler for PDF in IIS

I developed an HttpHandler in order to count number of downloads for PDF files.
Now the problem is: How can I make IIS use my handler for PDF files?
For IIS 7 it does depend on which mode you are running IIS in. Microsoft has a great tutorial on this How to: Register HTTP Handlers which goes over all the different configuration scenarios but assuming you are running IIS 7 in integrated mode and your handler is a compiled binary you would need a web.config entry similar to the following:
<configuration>
<system.webServer>
<handlers>
<add name="pdfCountHandler" verb="*"
path="*.pdf"
type="<your handler class name>, <your handler assembly name>"
resourceType="Unspecified" />
</handlers>
</system.webServer>
</configuration>

Can we implement the URL Reqwriting on IIS in shared hosting?

Can we implement the URL Re Writing Of IIS level on a shared hosting provider? According to my findings we can't but our project manager said we can.
possible very much using HttpHandlers e.g.
<httpModules>
<add type="URLRewriter.ModuleRewriter, URLRewriter"
name="ModuleRewriter" />
</httpModules>
<httpHandlers>
<add verb="*" path="*.aspx"
type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
</httpHandlers>
More info at this link
Maybe you can use Rewrite feature of IIS 7.5 , please refer following link for guidance
http://www.iis.net/learn/extensions/url-rewrite-module/using-rewrite-maps-in-url-rewrite-module

Configure IHttpHandler in the Test Web Server

I am trying to implement an IHttpHandler. I have defined an appropriate class but the debug web server (you know, the one you get if you hit f5 in Visual Studio) is responding with "Can't Display Page".
I looked here http://msdn.microsoft.com/en-us/library/ms228090%28v=VS.90%29.aspx to learn how to configure the handler, and it seems there are different ways for IIS6 and 7. But the process is put something in the web.config and then set it up in IIS Manager. However, that is a deployment issue. I want to be able to run it in the test server, and I don't know how to do this second step in the test server.
I put the following in my web.config:
<httpHandlers>
<add verb="*" path="*.sample"
type="MyNamespace.Code.HelloWorldHandler"/>
</httpHandlers>
HelloWorldHandler is the code from the link above (wrapped in MyNamespace.)
Can someone let me know how to configure this correctly for the development server?
You should be able to set the web server settings via web.config like this...
<configuration>
<system.webServer>
<handlers>
<add name="HelloWorldHandler"
verb="*"
path="*.sample"
type="MyNamespace.Code.HelloWorldHandler"
resourceType="Unspecified" />
<handlers>
</system.webServer>
</configuration>

how to include my asp.net website under sharepoint?

I i have the asp.net web site with c# + sql server 2008 connectivity + css + javascripts + ajax . I have a solution. i want to run this site under sharepoint . What i have to do for integrate this ?
You need to create an sub-directory that acts as a buffer to block/remove the inherited items from the .net 2 / 3.5 framework and then create your application under this.
Assuming you name the buffer application apps, and your custom .NET 4.0 application is called myapp, your resulting application would reside at:
http://[sharepoint-site]/apps/myapp/
How to do this:
Create a sub-directory apps under the root of your SharePoint
site
Go into security for the apps directory and add everyone with Read permissions
In IIS, convert this to an application and pick the same app-pool
that your SharePoint site is running under
Create a web.config under /apps/, this will block/remove the
SharePoint stuff (see below for the code block)
Create your myapp directory under apps (ex. /apps/myapp/)
In IIS, go into Application Pools, create a new AppPool, MyApp .NET v4.0
Go into Advanced Settings > Identity and add the same AD domain user account
credentials that your SharePoint site is using
Still in IIS, go back to myapp and convert to an application and pick the MyApp .NET v4.0 AppPool
Copy your code over and you're done!
The web.config file in the apps directory:
<?xml version="1.0"?>
<configuration>
<system.web>
<httpHandlers>
<remove path="Reserved.ReportViewerWebControl.axd" verb="*" />
</httpHandlers>
<httpModules>
<clear/>
</httpModules>
<webParts>
<transformers>
<clear />
</transformers>
</webParts>
</system.web>
<system.webServer>
<handlers>
<remove name="OwssvrHandler" />
<remove name="ScriptHandlerFactory" />
<remove name="svc-Integrated" />
<remove name="ScriptHandlerFactoryAppServices" />
<remove name="ScriptResource" />
<remove name="JSONHandlerFactory" />
<remove name="ReportViewerWebPart" />
<remove name="ReportViewerWebControl" />
</handlers>
<modules>
<!-- depending on any customizations, you may have to add/remove items from this list as needed -->
<remove name="SPRequestModule" />
<remove name="ScriptModule" />
<remove name="SharePoint14Module" />
<remove name="StateServiceModule" />
<remove name="PublishingHttpModule" />
<remove name="RSRedirectModule" />
</modules>
<httpErrors errorMode="Detailed"></httpErrors>
</system.webServer>
</configuration>
There are several options. The first is a simple IFrame webpart that hosts the entire application in a frame. The page viewer webpart is built into sharepoint, and does this for you.
The second is using Application Pages. I have not done this, but here is an MSDN article on them:
http://msdn.microsoft.com/en-us/library/bb418732.aspx
The third is to embed the controls of you app into Webparts, and then place these into web part zones on sharepoint pages.
The approach you take depends on the size of your app and the time you have to integrate it. The IFrame Approach is quick and dirty, while the webpart approach is much more native, but can take a long time for large apps.
I haven't had any luck trying to get another site to co-exist with SharePoint. Is it not possible for you to create this site of yours in its own web site, with its own app pool, and then just link to it from SharePoint?

Resources