Fileupload.ashx

Sep 3, 2010 at 9:10 PM

This worked great on my production machine, but when I published it to the web, I got an error that it was missing the Fileupload.ashx file.

What should I do?

Thanks.

Reese

Sep 3, 2010 at 9:59 PM
Edited Sep 3, 2010 at 10:01 PM

Please ensure you've set your web config as shown in the quick start or sample documentation by ensuring your web config contains the following in the <system.webServer> section.

<handlers>
    <add name="FileDownload" verb="GET,POST" path="FileDownload.ashx" type="HSS.Interlink.Web.FileDownload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903"/>
    <add name="FileUpload" verb="GET,POST" path="FileUpload.ashx" type="HSS.Interlink.Web.FileUpload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903"/>
</handlers>

If your web server is not IIS 7.X (IIS Versions is less than 7.0), then the web config needs to be modified as follows.

In the <system.web> section of your web config add this...

<httpHandlers>
    <add verb="GET,POST" path="FileDownload.ashx" type="HSS.Interlink.Web.FileDownload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903" />
    <add verb="GET,POST" path="FileUpload.ashx" type="HSS.Interlink.Web.FileUpload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903" />
</httpHandlers>

And remove the following from the <system.webServer> section

<handlers>
    <add name="FileDownload" verb="GET,POST" path="FileDownload.ashx" type="HSS.Interlink.Web.FileDownload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903"/>
    <add name="FileUpload" verb="GET,POST" path="FileUpload.ashx" type="HSS.Interlink.Web.FileUpload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903"/>
</handlers>

To confirm, you do not need a physical *.ashx file. The entries above map any request for FileUpload.ashx to the HSS Interlink Handlers, regardless of any physical file.

Again, if you need help or have more questions, please let me know..

 

 

 

Sep 3, 2010 at 10:19 PM

To confirm the difference in configuration, depending on whether or not you're running from Visual Studio or IIS 6 versus IIS 7.X, I've updated the Sample Documentation to more cleary specify how to set the config appropriately.

 

 

Sep 4, 2010 at 2:07 PM
Edited Sep 4, 2010 at 2:11 PM

Thanks for working with me on this.  Unfortunately, I'm still getting the error.  Here's what I've done:

1) Since I'm using IIS 7, I've copied the first section of code and put it in the <system.WebServer> of the web config file.  (I also removed the other entries from the <system.Web file>)

2) I checked my IIS setup and saw that it does have about five entries listed as ".ashx" under the "Handle mappings".  So, that part appears to be ok.

FYI, here's the error message I'm getting in Fidder:

<span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>

<h2> <i>The resource cannot be found.</i> </h2></span>

<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

<b> Description: </b>HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. &nbsp;Please review the following URL and make sure that it is spelled correctly.

<br><br>

<b> Requested URL: </b>/FileUpload.ashx<br><br>
And here's my web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <sectionGroup name="system.serviceModel">
      <section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" allowDefinition="MachineToApplication" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <appSettings>
    <!-- This value must match the Full TypeName including the namespace of your UploadHandler -->
    <add key="UploadHandler" value="CIJobForm.Web.UploadHandler, CIJobForm.Web"/>
  </appSettings>
  <connectionStrings>
    <remove name="LocalSqlServer" />
    <!--<add name="LocalSqlServer" connectionString="Data Source=REESE-VOSTRO\SQLEXPRESS;Initial Catalog=aspnetdb;User ID=RKW;Password=rkw1149;Integrated Security=False;" providerName="System.Data.SqlClient" />
    <add name="Entities" connectionString="metadata=res://*/CustomerModel.csdl|res://*/CustomerModel.ssdl|res://*/CustomerModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=REESE-VOSTRO\SQLEXPRESS;Initial Catalog=ASPNETDB;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />-->
    <add name="LocalSqlServer" connectionString="Data Source=SQLSERVER;Initial Catalog=aspnetdb;User ID=RKW;Password=*********;Integrated Security=False;" providerName="System.Data.SqlClient" />
    <add name="Entities" connectionString="metadata=res://*/CustomerModel.csdl|res://*/CustomerModel.ssdl|res://*/CustomerModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=SQLSERVER;Initial Catalog=aspnetdb;User ID=RKW;Password=*********;Integrated Security=False;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <system.web>
    <!-- This was added as part of the Upload installation -->
    <!--<httpHandlers>
      <add verb="GET,POST" path="FileUpload.ashx"  type="HSS.Interlink.Web.FileUpload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903" />
    </httpHandlers>-->
    <httpModules>
      <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </httpModules>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <roleManager enabled="true" />
    <authentication mode="Forms">
      <forms name=".CIJobForm_ASPXAUTH" />
    </authentication>
    <profile>
      <properties>
        <add name="FriendlyName" />
      </properties>
    </profile>
    <!-- Added 8/19/2010 to see error on CI machine-->
    <customErrors mode="Off" />
    <membership>
      <providers>
        <clear />
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, &#xD;&#xA;           Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" applicationName="/" requiresUniqueEmail="true" passwordFormat="Clear" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
        <!--passwordFormat="Hashed"-->
      </providers>
    </membership>
  </system.web>


  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <add name="DomainServiceModule" preCondition="managedHandler" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
    <!-- This was added as part of the Upload installation -->
    <handlers>
      <add name="FileDownload" verb="GET,POST" path="FileDownload.ashx" type="HSS.Interlink.Web.FileDownload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903"/>
      <add name="FileUpload" verb="GET,POST" path="FileUpload.ashx" type="HSS.Interlink.Web.FileUpload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903"/>
    </handlers>
  </system.webServer>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
</configuration>
Sep 4, 2010 at 2:43 PM

If your app is a sub app in IIS, you may need to override the UploadFileDialog.UploadUri which defaults to /FileUpload.ashx.

udialog.UploadUri = "/yoursubsite/fileupload.ashx";

Also to provide further clarification, <system.webServer> is for  IIS 7.0 running in Integrated Mode.  This means your AppPool that is running your site, must be set to .NET 4.0.30319 and set to Integrated Mode. If it’s Classic Mode, then you have to use the <system.web> httpHandler.

Here is an article from MSDN explaining in detail: http://msdn.microsoft.com/en-us/library/46c5ddfy.aspx

If this doesn’t work, then I will have to continue investigating…

Sep 5, 2010 at 7:37 PM

That fixed it for me!  I just need to include the application name in the file path.

Thanks a bunch.

Sep 5, 2010 at 7:51 PM

Excellent, glad to hear that solved your issue.

Dec 2, 2010 at 10:29 AM

My application environment: IIS 7, Custom ApplicationPool with .Net Fraimwork 4.0.30319, Managed pipeline mode - Intergrated

You control must be registered in Web.config as you write...

Question: How i may config my application, without change environment, that your control works correctly?

Dec 2, 2010 at 11:29 AM

To confirm, the config entries are to register the http handler. And the handler URI is virtual, there is no file named UploadHandler.ashx.

Can you clarify what you mean when you say "without changing your environment"? Do you mean without changing your config?

The idea is you drop the Interlink dll into the your bin folder, make the web.config changes write your File Handler (which can be in your web site project or a separate dll) and then consume from silverlight.

If you havent already, you can check out the Quick Start Guide here http://interlink.codeplex.com/wikipage?title=quickstart it demonstrates the minimal requirements to implement interlink.

For a complete walk thru of all the features check out the full documentation here http://interlink.codeplex.com/documentation

Thanks for inquiring, happy to help!

 

Nov 18, 2011 at 7:30 PM

I have a similar problem.

I am running IIS7.5 integrated and can upload files through my Visual Studio Dev Server without a problem but when I change the web config handlers and publish my app I cannot upload files. I get a Not found error.

If I try and navigate to the FileUpload.ashx from the browser on the production server I get an HTTP Error 404 Not Found page with the Detailed Error information shown below

Module ManagedPipelineHandler
Notification ExecuteRequestHandler
Handler FileUpload
Error Code 0x00000000
Requested URL http://192.168.1.155:80/FileUpload.ashx
Physical Path C:\inetpub\wwwroot\CARBFiles\FileUpload.ashx
Logon Method Anonymous
Logon User Anonymous

My Web.config is below

 <?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>
   <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <handlers>
      <add name="FileDownload" verb="GET,POST" path="FileDownload.ashx" type="HSS.Interlink.Web.FileDownload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903"/>
      <add name="FileUpload" verb="GET,POST" path="FileUpload.ashx" type="HSS.Interlink.Web.FileUpload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903"/>
    </handlers>
  </system.webServer>
</configuration>

Nov 18, 2011 at 8:06 PM

The problem is your production version is a sub application, not a root application (http://domain.com/carbfiles/) so you need to modify the web config to include your sub app.

replace your prod config with this...

<add name="FileDownload" verb="GET,POST" path=carbfiles/FileDownload.ashx" type="HSS.Interlink.Web.FileDownload, HSS.Interlink.Web" />
<add name="FileUpload" verb="GET,POST" path="carbfiles/FileUpload.ashx" type="HSS.Interlink.Web.FileUpload, HSS.Interlink.Web" />

Note: I removed the version and token info from the type reference. That is so regardless of what version you have in the bin folder it work. This is optional, just wanted to explain why.

Nov 18, 2011 at 8:10 PM

Also, the reason you get an error trying to navigate directly to the ashx uri is a security measure within interlink to prevent hack attempts from reaching the http handler.

Nov 18, 2011 at 9:13 PM

I'm still getting the NotFound error uploading.

Also I noticed something strange, when I navigate to http://localhost/CARBfiles/FileUpload.ashx it gives me a Server Error in Application message.
Could not load file or assembly 'HSS.Interlink.Web' or one of its dependencies. The system cannot find the file specified.

The HSS.Interlink.Web.dll and xml files are in the CARBfiles/bin folder

Nov 18, 2011 at 9:16 PM

Sorry, my bad, I forgot you have to also update the HandlerUri setting on the UploadDialog to point to CARBFiles/FileUpload.ashx

var d = new UploadFileDialog();
d.UploadUri = "carbfiles/fileupload.ashx";
d.Show();

Nov 18, 2011 at 9:39 PM

I'm still getting the remote server returned an error NotFound. Could it be the folder permissions or something maybe?

Nov 21, 2011 at 4:44 AM

Glad you got your server fixed and working.

Nov 21, 2011 at 10:54 PM

Thanks again for all your help and just to point out for anyone else that might happen upon this it was this line of code in my web config that was causing the last problem.
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
Thanks!!

Oct 8, 2013 at 12:08 PM
Edited Oct 8, 2013 at 12:17 PM
Hi hyspdrt,

This is demo file from HSS website.

I've tried all your tips and tricks and cannot get it work on IIS 7 server in classic mode.

I wuold love if you can check my settings and give me direction.

This is my web.config
    <add key="UploadHandler" value="LightSwitchApplication.UploadHandler, Application.Server" />
    <add key="AllowAllWindowsUsers" value="true" />
  </appSettings>
  <connectionStrings>
    <add name="_IntrinsicData" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|ApplicationDatabasePath|;Integrated Security=True;Connect Timeout=30;MultipleActiveResultSets=True;" />
  </connectionStrings>
  <system.web>
    <!-- LightSwitch trace.axd handler -->
    <trace enabled="true" localOnly="false" requestLimit="40" writeToDiagnosticsTrace="false" traceMode="SortByTime" mostRecent="true" />
    <httpHandlers>
      <add verb="GET" path="trace.axd" type="Microsoft.LightSwitch.WebHost.Implementation.TraceHandler,Microsoft.LightSwitch.Server.Internal,Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      <add verb="GET,POST" path="FileUpload.ashx" type="HSS.Interlink.Web.FileUpload, HSS.Interlink.Web" />
    </httpHandlers>
And this is the code
UploadFileDialog d;

partial void UploadFile_Execute()
{
    System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
    {
        d = new UploadFileDialog();
        d.UploadUri = "Application1/FileUpload.ashx";
        d.MaxFileSizeKB = int.MaxValue;
        d.AutoUpload = true;
        d.AllowFileOverwrite = true;
        d.Background = new System.Windows.Media.SolidColorBrush(Colors.Gray);
        d.Closed += new EventHandler(d_Closed);
        Microsoft.LightSwitch.Threading.Dispatchers.Current.BeginInvoke(() =>
        {
            d.Show();
        });
    });
}
The Fiddler web debuger tells me this:
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /Application1/FileUpload.ashx
What I'm doing wrong?

Also, another question: How can I get a list of uploaded files, after succesfull upload?

I've tried check d.uploadedcount and it gives me proper number, but d.files is empty.

HSS.Interlink v.2.2.100.0
HSS.Interlink.Web v 2.2.100.0

Thanks.
Oct 8, 2013 at 12:43 PM
At first blush, it appears your app is a sub-app (http://domain.com/application1)

If that is true, then your web config needs to be path="/application1/fileupload.ashx"