Search code examples
httpurihttphandlerashx

Generic Handler + UriBuilder


I'm creating a Silverlight uploader using a generic handler and asp. The app runs, but when I try to deploy to the localhost server or the production server the app just doesn't work properly. I thing the problem is in the URI of the Generic Handler.

            //I THINK THE PROBLEM IS IN THIS LINE
            UriBuilder ub = new UriBuilder("http://localhost:3840/receiver.ashx");

            ub.Query = string.Format("filename={0}", fileName);
            WebClient c = new WebClient();
            c.OpenWriteCompleted += (sender, e) =>
            {
                PushData(data, e.Result);
                e.Result.Close();
                data.Close();
            };
            c.OpenWriteAsync(ub.Uri);

Which is the correct format of the generic handler url when I deploy the app to the server and how can I test the handler to check is everything is going ok?

Thanks


Solution

  • Use following 2 lines to define ub on your production server: (vb code) Dim u As Uri = New Uri(Application.Current.Host.Source, "../receiver.ashx") Dim ub As New UriBuilder(u.OriginalString)