Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
C# ASP.NET Proxy
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  14 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ian Turner  
View profile  
 More options Apr 18 2012, 5:54 am
From: Ian Turner <ianatur...@gmail.com>
Date: Wed, 18 Apr 2012 02:54:06 -0700 (PDT)
Local: Wed, Apr 18 2012 5:54 am
Subject: C# ASP.NET Proxy

I've seen a few AtD users having issues with the issue of creating a proxy
for AtD server requests in a c# environment, so I thought I'd post mine
here.

I'm running the proxy within an ASP.NET MVC application, using jQuery and
AtD's checkTextarea API method.

In my jquery.atd.textarea.js, I need to configure the rpc (for jQuery.ajax
calls from the AtD API check method) and rpc_css (for CSSHttpRequest calls
from the AtD API checkCrossAJAX method) properties to hit the proxy on my
web server:

        rpc: 'CheckSpelling.proxy',
        rpc_css: 'CheckSpelling.proxy?data=',

Here's the entire proxy class itself (AtDProxyHandler.cs):

using System.Configuration;
using System.IO;
using System.Net;
using System.Web;
using System.Web.Routing;

namespace [YourProjectNamespace].Helpers
{
    /// <summary>
    /// Definition of the AtDProxyHandler class that receives routing
requests, as defined in Helpers.RouteMapping, calls the AfterTheDeadline
server and returns the result.
    /// </summary>
    public class AtDProxyHandler : IHttpHandler, IRouteHandler
    {
        #region Constructor

        /// <summary>
        /// Initializes a new instance of the AtDProxyHandler class.
        /// </summary>
        public AtDProxyHandler()
        {
            ProxiedUrl = string.Format(
                "{0}/{1}?{2}=",
                ConfigurationManager.AppSettings["AtDServer"],
                ConfigurationManager.AppSettings["SpellCheckUrl"],
                ConfigurationManager.AppSettings["SpellCheckDataId"]
            );
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the proxied URL that will be called by
ProcessRequest.
        /// </summary>
        public string ProxiedUrl { get; set; }

        /// <summary>
        /// Gets a value indicating whether the handler IsReusable.
        /// </summary>
        public bool IsReusable
        {
            get { return true; }
        }

        #endregion

        /// <summary>
        /// Implements the ProcessRequest method required by IHttpHandler.
        /// </summary>
        /// <param name="context">The HttpContext wrapping the
request.</param>
        public void ProcessRequest(HttpContext context)
        {
            // assemble a new HTTP request to the proxied URL
            string dataId =
ConfigurationManager.AppSettings["SpellCheckDataId"].ToString();
            string data = context.Request.RequestType == "GET" ?
context.Request.QueryString[dataId] : context.Request.Form[dataId];
            string requestStr = string.Format("{0}{1}", ProxiedUrl, data);
            HttpWebRequest request =
(HttpWebRequest)WebRequest.Create(requestStr);
            request.Method = "GET";

            // get the response from the AtD server
            HttpWebResponse response =
(HttpWebResponse)request.GetResponse();
            StreamReader reader = new
StreamReader(response.GetResponseStream());

            // return the response, with appropriate encoding
            context.Response.ContentType = context.Request.ContentType ==
"application/x-www-form-urlencoded" ? "text/xml" : "text/css";
            context.Response.StatusCode = 200;
            string responseStr = reader.ReadToEnd();
            context.Response.Write(responseStr);
            context.Response.End();
        }

        /// <summary>
        /// Implements the GetHttpHandler method required by IHttpHandler.
        /// </summary>
        /// <param name="requestContext">The HttpContext wrapping the
request.</param>
        /// <returns>A valid HttpHandler instance.</returns>
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            return this;
        }
    }

}

You'll notice in the class constructor that I've tried to make this
generic, and use a number of web.config setting to abstract the server URL
(I pick that up later in my Windows service):

<configuration>
    :
    <appSettings>
        <add key="AtDServer" value="http://127.0.0.1:1049"/>
        <add key="SpellCheckUrl" value="checkDocument"/>
        <add key="SpellCheckDataId" value="data"/>
    </appSettings>
    :

In order for a request to hit this class (bearing in mind that my
application is MVC based), you'll need a route configuring in your
Global.asax.cs RegisterRoutes() method:

    // custom routes
    :

    // spell-checking proxy
    string[] allowedMethods = { "GET", "POST" };
    HttpMethodConstraint methodConstraints = new
HttpMethodConstraint(allowedMethods);
    routes.Add(
        new Route(
                "{name}/{*everythingelse}",
                new RouteValueDictionary(),
                new RouteValueDictionary(new { name =
"CheckSpelling.Proxy", httpMethod = methodConstraints }),
                new [YourProjectNamespace].Helpers.AtDProxyHandler()
        )
    );

    // the default controller/action route interpreter for an MVC
application
    routes.MapRoute(
        "Default",                                              // Route
name
        "{controller}/{action}/{id}",                           // URL with
parameters
        new { controller = "Home", action = "Index", id = string.Empty }  //
Parameter defaults
    );

And that's it. You can put a breakpoint in the ProcessRequest() method and
have hours of fun watching your request and response

:0)

Regards
Ian


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Darron Haworth  
View profile  
 More options Apr 18 2012, 1:50 pm
From: Darron Haworth <darron.hawo...@gmail.com>
Date: Wed, 18 Apr 2012 10:50:04 -0700
Local: Wed, Apr 18 2012 1:50 pm
Subject: Re: [atd-developers] C# ASP.NET Proxy

Ian,

I got it working.  The atd_server files were included in the project, when
I removed them from the csproj and tried again it started.

THANK YOU  SO MUCH for all your help!

Now I'm looking at your post about the MVC proxy stuff.

Darron


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Darron Haworth  
View profile  
 More options Apr 19 2012, 6:45 pm
From: Darron Haworth <darron.hawo...@gmail.com>
Date: Thu, 19 Apr 2012 15:45:46 -0700
Local: Thurs, Apr 19 2012 6:45 pm
Subject: Re: [atd-developers] C# ASP.NET Proxy

Ian,

I'm not sure I followed the first part of this:
----------------------------------
In my jquery.atd.textarea.js, I need to configure the rpc (for jQuery.ajax
calls from the AtD API check method) and rpc_css (for CSSHttpRequest calls
from the AtD API checkCrossAJAX method) properties to hit the proxy on my
web server:

        rpc: 'CheckSpelling.proxy',
        rpc_css: 'CheckSpelling.proxy?data=',
----------------------------------
I've added the custom route, the web.config stuff, and the proxy but not
sure how to use it... Do I need to edit the jScript files that AtD use?

Thanks,
Darron


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Turner  
View profile  
 More options Apr 19 2012, 6:50 pm
From: Ian Turner <ianatur...@gmail.com>
Date: Thu, 19 Apr 2012 23:50:31 +0100
Local: Thurs, Apr 19 2012 6:50 pm
Subject: Re: [atd-developers] C# ASP.NET Proxy

Exactly - find the variables rpc and rpc_css in jquery.atd.textarea.js and
edit those as shown... Then when you call checkTextArea() it should hit
your proxy class's ProcessRequest method - put a breakpoint in there to see
it get hit

Sent from my iPhone4S

On 19 Apr 2012, at 23:45, Darron Haworth <darron.hawo...@gmail.com> wrote:

Ian,

I'm not sure I followed the first part of this:
----------------------------------
In my jquery.atd.textarea.js, I need to configure the rpc (for jQuery.ajax
calls from the AtD API check method) and rpc_css (for CSSHttpRequest calls
from the AtD API checkCrossAJAX method) properties to hit the proxy on my
web server:

        rpc: 'CheckSpelling.proxy',
        rpc_css: 'CheckSpelling.proxy?data=',
----------------------------------
I've added the custom route, the web.config stuff, and the proxy but not
sure how to use it... Do I need to edit the jScript files that AtD use?

Thanks,
Darron

 --
You received this message because you are subscribed to the Google Groups
"AtD Developers" group.
To post to this group, send email to atd-developers@googlegroups.com
To unsubscribe from this group, send email to
atd-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/atd-developers?hl=en

You can find more on After the Deadline at
http://www.afterthedeadline.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Darron Haworth  
View profile  
 More options Apr 19 2012, 6:53 pm
From: Darron Haworth <darron.hawo...@gmail.com>
Date: Thu, 19 Apr 2012 15:53:51 -0700
Local: Thurs, Apr 19 2012 6:53 pm
Subject: Re: [atd-developers] C# ASP.NET Proxy

Ah, I found it a few minutes ago...  I re-read what you wrote and it made
total sense.   I need some more caffeine!

Thanks, you have helped me so much!

I tried some other products, wasted half a day on JSpell Evolution for the
VP just to find out that it is very buggy.  I am going to recommend AtD!

I am about to test the complete AtD local server/proxy in my MVC project,
I'll let you know how it goes. :)

-Darron


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Turner  
View profile  
 More options Apr 19 2012, 6:59 pm
From: Ian Turner <ianatur...@gmail.com>
Date: Thu, 19 Apr 2012 23:59:09 +0100
Local: Thurs, Apr 19 2012 6:59 pm
Subject: Re: [atd-developers] C# ASP.NET Proxy

Well you should already know that your service is working from entering
that browser URL while it was running, so all you have to do is join the
dots to it from the front end jquery via the proxy. That's the easier bit.

I'm testing my version 2 of jquery.atd.textarea.js and will be passing it
to the redesign group next week. Hopefully they'll approve my
re-architecture of it and we can release the initial version soon.

Good luck anyway

Cheers
Ian

Sent from my iPhone4S

On 19 Apr 2012, at 23:53, Darron Haworth <darron.hawo...@gmail.com> wrote:

Ah, I found it a few minutes ago...  I re-read what you wrote and it made
total sense.   I need some more caffeine!

Thanks, you have helped me so much!

I tried some other products, wasted half a day on JSpell Evolution for the
VP just to find out that it is very buggy.  I am going to recommend AtD!

I am about to test the complete AtD local server/proxy in my MVC project,
I'll let you know how it goes. :)

-Darron

 --
You received this message because you are subscribed to the Google Groups
"AtD Developers" group.
To post to this group, send email to atd-developers@googlegroups.com
To unsubscribe from this group, send email to
atd-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/atd-developers?hl=en

You can find more on After the Deadline at
http://www.afterthedeadline.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Darron Haworth  
View profile  
 More options Apr 19 2012, 7:10 pm
From: Darron Haworth <darron.hawo...@gmail.com>
Date: Thu, 19 Apr 2012 16:10:55 -0700
Local: Thurs, Apr 19 2012 7:10 pm
Subject: Re: [atd-developers] C# ASP.NET Proxy

Yes, my service is working fine, I hit it with the data querystring and it
displays the xml results...

I am not hitting my proxy right now after making all the changes in the MVC
piece...  I hope this piece is easier, I don't have another couple of days
on this.  ;)

You mention "for jQuery.ajax calls from the AtD API check method)"

I was using the jQuery (jquery.atd.textarea.js) Should I be using
jquery.atd.js instead?

Thanks!

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Turner  
View profile  
 More options Apr 19 2012, 7:24 pm
From: Ian Turner <ianatur...@gmail.com>
Date: Fri, 20 Apr 2012 00:24:09 +0100
Local: Thurs, Apr 19 2012 7:24 pm
Subject: Re: [atd-developers] C# ASP.NET Proxy

No, jquery.atd.textarea.js is the meat of it.

Again forgive me, I don't have the code in front of me (it's after midnight
and I'm in the bath!)...

You should be able to set a JavaScript breakpoint inside
jquery.atd.textarea.js's checkTextArea() function using Firebug (for
Firefox) or the script debugger in Chrome, then see your textarea replaced
with a div, and finally a call to the proxy URL via the check() function...
Or maybe you're calling checkCrossAjax() instead?

 If you like, I can document the front end, illustrating the entire chain
of function calls (I was thinking of writing a cradle-to-grave article
aimed at MVC projects tomorrow anyway, and have most of it down)...

I'll be in the office in 9 hours time, and can send it an hour later.

Sent from my iPhone4S

On 20 Apr 2012, at 00:10, Darron Haworth <darron.hawo...@gmail.com> wrote:

Yes, my service is working fine, I hit it with the data querystring and it
displays the xml results...

I am not hitting my proxy right now after making all the changes in the MVC
piece...  I hope this piece is easier, I don't have another couple of days
on this.  ;)

You mention "for jQuery.ajax calls from the AtD API check method)"

I was using the jQuery (jquery.atd.textarea.js) Should I be using
jquery.atd.js instead?

Thanks!

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Darron Haworth  
View profile  
 More options Apr 19 2012, 7:24 pm
From: Darron Haworth <darron.hawo...@gmail.com>
Date: Thu, 19 Apr 2012 16:24:17 -0700
Local: Thurs, Apr 19 2012 7:24 pm
Subject: Re: [atd-developers] C# ASP.NET Proxy

Ian,

Is it possible to test my proxy from url like I did my service?

Like this:
http://dev-fulfillmentportal.sterlingdirect.com/CheckSpelling.proxy?d...

??


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Turner  
View profile  
 More options Apr 19 2012, 7:26 pm
From: Ian Turner <ianatur...@gmail.com>
Date: Fri, 20 Apr 2012 00:26:23 +0100
Local: Thurs, Apr 19 2012 7:26 pm
Subject: Re: [atd-developers] C# ASP.NET Proxy

Yes. But that should end with ...?data=thsi+is+a+tst

Sent from my iPhone4S

On 20 Apr 2012, at 00:24, Darron Haworth <darron.hawo...@gmail.com> wrote:

Ian,

Is it possible to test my proxy from url like I did my service?

Like this:
http://dev-fulfillmentportal.sterlingdirect.com/CheckSpelling.proxy?d...

??

 --
You received this message because you are subscribed to the Google Groups
"AtD Developers" group.
To post to this group, send email to atd-developers@googlegroups.com
To unsubscribe from this group, send email to
atd-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/atd-developers?hl=en

You can find more on After the Deadline at
http://www.afterthedeadline.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Darron Haworth  
View profile  
 More options Apr 19 2012, 7:27 pm
From: Darron Haworth <darron.hawo...@gmail.com>
Date: Thu, 19 Apr 2012 16:27:23 -0700
Local: Thurs, Apr 19 2012 7:27 pm
Subject: Re: [atd-developers] C# ASP.NET Proxy

That would be awesome, I'll switch back to my jquery.atd.textarea.js and
step through the client side script...

I never hit the breakpoint that I placed indied the AtDProxyHandler.cs
(ProcessRequest() method) ...

I hate to bug you, so late.   Where are you located?  I am in Rocklin,
California...

Good night,
Darron

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Darron Haworth  
View profile  
 More options Apr 19 2012, 7:29 pm
From: Darron Haworth <darron.hawo...@gmail.com>
Date: Thu, 19 Apr 2012 16:29:49 -0700
Local: Thurs, Apr 19 2012 7:29 pm
Subject: Re: [atd-developers] C# ASP.NET Proxy

Ah, I get a 404 so maybe an issue with my custom route?  I am new to MVC,
new to AtD, new to Window services, new to WCF, new to Entity Framework,
and working on a project with all of these.  My mind is about to melt!

Later,
Darron


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Turner  
View profile  
 More options Apr 19 2012, 7:29 pm
From: Ian Turner <ianatur...@gmail.com>
Date: Fri, 20 Apr 2012 00:29:57 +0100
Local: Thurs, Apr 19 2012 7:29 pm
Subject: Re: [atd-developers] C# ASP.NET Proxy

I'm in Leeds, England.

It's no bother.

I'm not sure if it's case sensitive or not, but just to be sure, try to hit
/CheckSpelling.Proxy (uppercase P) as configured in your route?

Sent from my iPhone4S

On 20 Apr 2012, at 00:27, Darron Haworth <darron.hawo...@gmail.com> wrote:

That would be awesome, I'll switch back to my jquery.atd.textarea.js and
step through the client side script...

I never hit the breakpoint that I placed indied the AtDProxyHandler.cs
(ProcessRequest() method) ...

I hate to bug you, so late.   Where are you located?  I am in Rocklin,
California...

Good night,
Darron

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Turner  
View profile  
 More options Apr 19 2012, 7:32 pm
From: Ian Turner <ianatur...@gmail.com>
Date: Fri, 20 Apr 2012 00:32:42 +0100
Local: Thurs, Apr 19 2012 7:32 pm
Subject: Re: [atd-developers] C# ASP.NET Proxy

Ha! Very brave! Still, without stretching ourselves, life would be boring,
huh?

I know the feeling - I had to do the same, then train my colleagues shortly
afterwards (only with NHibernate instead of EF)

Never looked back though - so stick with it, its worth it! You have my
admiration for your bravery!

Sent from my iPhone4S

On 20 Apr 2012, at 00:29, Darron Haworth <darron.hawo...@gmail.com> wrote:

Ah, I get a 404 so maybe an issue with my custom route?  I am new to MVC,
new to AtD, new to Window services, new to WCF, new to Entity Framework,
and working on a project with all of these.  My mind is about to melt!

Later,
Darron

 --
You received this message because you are subscribed to the Google Groups
"AtD Developers" group.
To post to this group, send email to atd-developers@googlegroups.com
To unsubscribe from this group, send email to
atd-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/atd-developers?hl=en

You can find more on After the Deadline at
http://www.afterthedeadline.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »