Showing posts with label browser. Show all posts
Showing posts with label browser. Show all posts

Wednesday, March 28, 2012

Accessing Request headers from asp.net web service, invoked using Ajax

I need a small help.

I have a web service, in which I have a web method, which detects the browser locale using asp.net request object.

If I invoke the web service directly from the browser, I am able to get the browser language from Request object'sHTTP_ACCEPT_LANGUAGEheader.

But If I invoke the same web method from some aspx using javascript XMLHttpRequest, I always get the request headerHTTP_ACCEPT_LANGUAGE null.

Is this the behavior of the web services.

Then how can I access the browser language setting for the current request in the web service.

Is there a way to invoke the web service with the same request settings as that of aspx page while using xmlhttp.

Thanks in Advance

Hi,

I saw that you got this issue answered byJohn Saunders athttp://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2341086&SiteID=1, Here is quotation:

You are unlikely to receive a browser language setting if the web service is not called from a browser.

Wednesday, March 21, 2012

A high level ATLAS implementation question.

Hello, we are looking into this technology for a project currently in design.

The project is comparable to a browser based chat application so for the purpose of this post I will use a chat example.

  • Five users join a chat session
  • One person types a message and sends it to the group
  • The list of chat messages is updated for each user.

    Let's say the app needs to scale to 10,000 users and the messages are stored in a database and managed on the server.

    We could use Atlas to send the message to the server when the user clicks Send – this works great. My dilemma is how to update each client with the new chat message. We have considered using a timer on the client and polling the server using Atlas for new messages. However, this seems inefficient and doesn't scale due to our capacity requirements and all the net traffic this could produce.

    Is there a way to employ more a broadcast model using the Atlas technology? Could we use an Event in the server code that makes anOnCompletecallback to each cleint who's joined the session? Is there another way to message from the server to multiple clients?

    Thanks in advance for any advice you can provide, links, documentation, examples, etc...

    Kind Regards.

    Sounds like you should use a "Broadcast Pattern".
    ie.
    - all active users become part of some "active user broadcast list" as they join a chat session
    - then some class/thread is invoked to broadcast the message to all users in the list
    In between or after you can store the message in a db or whatever.
    dev


    Dev, thanks for the response.

    Yes, the broadcast pattern is along the lines we're thinking. The question is how to implement this model.

    I imagine we could wire up an Event in the server code that would fire when there's a new message submitted by any client.

    How then would the server broadcast the message to each of the web clients who are participating (up to 10000). Could an individual thread be kept alive somehow on the server for each client? This is where we were thinking about the OnComplete logic supported by Atlas. It seems like there's an AJAX solution out there somewhere for this.

    Thanks in advance for any more advice.


    Hi Bill,

    Here is how you could implement your chat s/w:

    Server side:
    Create the below webmethods:
    1. UpdateMe_async()
    polls the db for new messages. When new messages are available it returns an array of messages and client ids.
    2. ReceiveMsg(messagestring, clientid, otherparams...)
    Receives and adds the message to the db.

    Client side:

    Do the following:
    Onload:
    Make an async call to UpdateMe_async() webmethod. Set the call back to a function say func_UpdateMe().
    func_UpdateMe()
    Displays messages.
    On send button click:
    Make a call to the ReceiveMsg() webmethod.


    Hope it helps!

  •