Reputation: 1779
I have a legacy .cfm (ColdFusion) page which used to process form data (from remote servers) and send users emails based on form data. Now I no longer use ColdFusion and instead hosting is at the 'free' ASP.NET (3.5). I am not sure how much control I have over that. But I was thinking if I can have a global.asax file where all requests (actually, form posts) going to the .cfm page get redirected to an aspx page where I can do the needed processing. How can this be done within a shared hosting providers limitations? I know I can create a Virtual Directory in IIS. For example, www.xyz.com/processform.cfm can be directed to www.xyz.com/processform.aspx?
Upvotes: 1
Views: 2173
Reputation: 1779
Koby Mizrahy was close to helping me. My problem was that I was running Blog Engine .NET 2.0 as the main application of my website in GoDaddy's IIS Classic Mode. So the .cfm extension were not processed by the ASP.NET engine and hence no changes to either Web.Config or Global.asax were helping. I had to change to Integrated mode. Here is what I did to fix:
In Web.Config, added this in the 'Handlers' node to make sure Form Posts to .cfm would be processed, otherwise I got some 405 error.
<add name="ColdFusion" path="*.cfm" verb="*" type="System.Web.StaticFileHandler" resourceType="Unspecified" preCondition="integratedMode" />
Then in global.asax, I had this in the Application_beginrequest handler
if (Request.Url.ToString().Contains("TourEmail-act.cfm"))//
{
Server.Transfer("/360Flash/TourEmail-act.aspx");
}
}
Problem solved! Thank you very much Mizrahy!
Upvotes: 0
Reputation: 1371
There are 2 ways to do it:
If you want to map each cfm file to an aspx page you can do it by adding the urlMapping collection to system.web section:
<system.web>
<urlMappings>
<add url="~/mypage.cfm" mappedUrl="~/mypage.aspx"/>
</urlMappings>
</system.web>
If you want to globally handle any request for .cfm file You can do it in global.asax in the Begin request event:
protected void Application_BeginRequest(object sender, EventArgs e)
{
if(HttpContext.Current.Request.CurrentExecutionFilePathExtension == ".cfm")
{
// Do what ever you need to do
}
}
Both ways are not dependent on the host so godaddy is not a problem.
In the first option the form data will be maintained whily in the second option you will have to write the logic to pass the form data to the page you want to redirect.
If I am not wrong, but I am not sure, maybe Server.Transfer maintains form data
Upvotes: 2