New to ASP.NET and IIS Question

B

BM

Hello,

Ok, Im new to using ASP.NET and IIS so im not sure how or where to post this
question but here goes:

I am running IIS 5.1 on WinXP. I need to process http POST messages sent
from another application that I dont have control over. The messages are
sent to a web page called test.htm . The message looks similiar to the
following:

data "POST /test.htm HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 101

status=02%2F01%2F04%2023%3A21%20TEST MESSAGE%20HELLO% A%0D%0A"

The question is since this is being sent to a .htm page can I get these
messages and somehow process these using ASP.NET. I dont have control over
that it goes to test.htm (instead of test.aspx).

With a windows form I have been able to open a socket connection and read
these messages live and create files, databases etc, but with IIS involved
on the same machine it locks that port (80) and would be nice if I could use
ASP.NET to process these.

Thanks..
BM
 
B

bruce barker

its a standard web form post. the data is in form field "status". the only
trick you need to do is map the .htm extension to asp.net processing for
your application (application properties tab of iis), and the following will
work

test.htm >>>
<%@ Page Language="c#" %>
<%
Response.Write("You sent:" + Request.Form["status"].Value);
%>


-- bruce (sqlwork.com)
 
B

BM

Bruce,

Thanks for your help. The information about the mapping of IIS works fine
for telling asp.net to work on .htm files correctly. I verified this with a
test application by renaming an .aspx file to .htm and that works fine for
web page browsing and messages intstigated by loading the test.htm page.

The issue that I still seem to have and dont fully understand what to do is:
This application that sends Post messages is not using a web form or any
form whatsoever. It is sending the Post message as I have shown to the .htm
page which I want take and parse and save into a file. I guess im still to
new to understand how these messages work as I come from a non web
background.

Im sure Im just missing something simple. Im placing my streamwriter code
in the page_load event as that is the only place I see where a post message
is handled. This may be my big mistake as the page is never really loaded,
Post messages are just sent to it. Is there an event which just receives
the Post message?

I have created a sample code-behind web application which writes to a test
output file to see if it everything is fine. When I use a browser to access
the test.htm page it responds correctly in the IIS log with a 200 message
and writes to my log with my debug strings as the page_load is probably
responding to the event. When I actually use the real application which is
sending the post messages without web forms the server log shows 405 which I
know is not good. Im stumped as what to do..

Thanks for any Help you can provide!

BM/

bruce barker said:
its a standard web form post. the data is in form field "status". the only
trick you need to do is map the .htm extension to asp.net processing for
your application (application properties tab of iis), and the following will
work

test.htm >>>
<%@ Page Language="c#" %>
<%
Response.Write("You sent:" + Request.Form["status"].Value);
%>


-- bruce (sqlwork.com)




BM said:
Hello,

Ok, Im new to using ASP.NET and IIS so im not sure how or where to post this
question but here goes:

I am running IIS 5.1 on WinXP. I need to process http POST messages sent
from another application that I dont have control over. The messages are
sent to a web page called test.htm . The message looks similiar to the
following:

data "POST /test.htm HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 101

status=02%2F01%2F04%2023%3A21%20TEST MESSAGE%20HELLO% A%0D%0A"

The question is since this is being sent to a .htm page can I get these
messages and somehow process these using ASP.NET. I dont have control over
that it goes to test.htm (instead of test.aspx).

With a windows form I have been able to open a socket connection and read
these messages live and create files, databases etc, but with IIS involved
on the same machine it locks that port (80) and would be nice if I could use
ASP.NET to process these.

Thanks..
BM
 
S

Steven Cheng[MSFT]

Hi BM,


Thanks for posting in the community!
From your description, you're wanting to manually send a post message to a
certain web page on a IIS server and also you'd like it to be processed by
ASP.NET runtime, yes?
If there is anything I misunderstood, please feel free to let me know.

I've reviewed the former messages and found that you've tried the Bruce's
suggestion and that worked well when you try visit the page via IE or other
browser but failed when you used other means to post it,yes? As for this
problem, I'd like to asked some further questions on it:
1. What component do you use to post a certain http post message?

2. What operations do you actually want to do in that certain webpage which
you'd like it to be processed by aspnet? Would you generate a simple sample
page and show use the detailed content(code logic) of it?

In addition, in ASP.NET you can also use the HTTPHandler to process a
certain type of http request. As for your situation, you can provide a
custom httphandler, for more information on developing a ASP.NET
HttpHandler, you may have a view on the following references:

#HttpHandlers
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconhttphandlers.asp?f
rame=true

#Inside IIS & ASP.NET
http://www.theserverside.net/articles/article.aspx?l=IIS_ASP

# Extending ASP.NET with HttpHandlers and HttpModules
http://www.devx.com/dotnet/Article/6962/0/page/3

#Exploring ASP.NET Session State and Cache data
http://www.codeproject.com/aspnet/exploresessionandcache.asp

Please check out the above suggestions and items. If you find any problems,
please feel free to post here.



Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
B

BM

Ahh!

This is what I was looking for: The HTTPHandler will solve my problem
exactly!

Thanks Steven.

BM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top