|
Hi All,
Im using C# , Visual Studio 2008, to learn a bit more about HTTP Modules and HTTP Handlers.
I understand why it is used for, however in trying to absorb the basics of the code it is a bit difficult.
Im trying to make a http module which recognizes session state management. Ie A user that must login with a password and if they login correctly then they have access to certain pages.
Another thing that springs to my curiousity is how you are able to establish the connection between the user interface(ie textbox values etc to what is specified in the http module), ie how do you make it work.
Can someone give me a rundown of how the above might work.
Regards
|
|
|
|
|
CrimeanTurtle2008 wrote: A user that must login with a password and if they login correctly then they have access to certain pages.
I don't think that HTTPModule is really needed for this. You can do this in the page level and I think that would be the appropriate choice than a HttpModule . This can be done by checking for the session in each page load which needs to be secured. More neat approach would be to create separate classes for secured and normal pages and derive your pages from it. You create two classes say NormalPage and SecuredPage both derived from System.Web.UI.Page
SecuredPage will have the session checking code. All the pages which needs to be secured, derive from SecuredPage . It's very easy to implement.
CrimeanTurtle2008 wrote: Another thing that springs to my curiousity is how you are able to establish the connection between the user interface
You don't access user interface elements from a HttpModule.
HttpModule sits in the request pipeline and allows programmers to examine the requests and take necessary actions if required. It is executed for every request. Most wide used example of HttpModules are URL-rewriting.
HttpHandler is responsible for handling the requests and supplying data. Assume you have to prevent access to all jpg files in your website, you can write a handler and hook the jpg extensions to this handler.
Hope this helps
|
|
|
|
|
Thanks very much for your help guys.
I understand the concepts but understanding the specific code in the event handlers is tricky.
Thanks
|
|
|
|
|
Hi All,
I have a form that has 2 datepicker controls on my form, like this -
<cc1:DatePicker id="dropoffdate" runat="server" imgDirectory="/images/" DateType="dd mmm yyyy"/>
<cc1:DatePicker id="pickupdate" runat="server" imgDirectory="/images/" DateType="dd mmm yyyy"/>
The forms method is POST and action is Backup.asp.
In Backup.asp this code loops through the forms controls that are in the forms _fieldorder.
<table cellpadding="0" cellspacing="0">
<tr>
<th colspan="2" valign="bottom">Thank you, the following information has been sent:/th>
<tr>
<% for each name in fieldOrder %>
<tr valign="top>
<td><strong><% = name %></strong></td>
<td><%= Request.Form(name) %>/td>
</tr>
<%next %>
</table>
When the code runs this is the result.
Thank you, the following information has been sent:
Fname deaanne cronin
email brownowl30@hotmail.com
homephone 02 65 433014
mobile 0427 190 676
Address 16 Edinglassie Drive Muswellbrook 2333 NSW
vehiclemake bhgv
model 123
series 456
year 1908
engine big
colour red
rego 0ld-mob
service Minor Service
comments test
dropoffdate
pickupdate
Drop_Off_Time 9:00 AM
Pick_Up_Time 12:30 PM
No dropoffdate or pickupdate is specified even though i entered one on the form datepicker controls. Can anyone help?
thanks
dee
modified on Tuesday, December 9, 2008 8:59 PM
|
|
|
|
|
Hi Everyone,
i finally found the answer on the page where i downloaded the control code.
had to refer to the control like this
request.form("dropoffdate$foo")
and it works then.
Hope this helps anyone that had the same problem.
dee
|
|
|
|
|
Thanks. Please don't use the "urgent" word when you post next time. This might be the reason that no one answered your question.
|
|
|
|
|
I've got an ASP .NET webpage with the following structure:
<asp:DataGrid ID="aGrid">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Repeater ID="aRepeater">
<HeaderTemplate>
<asp:Label ID="aLabel" Text='<%# DataBinder.Eval(Container.DataItem, "SomeColumn") %>'></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="aTextBox" AutoPostBack="true" OnTextChanged="SomeEvent"></asp:TextBox>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
The problem I'm having is that I would like to access the data that is stored in the label aLabel in the OnTextChanged event. What I'm doing to achieve this purpose is:
void SomeEvent(object sender, EventArgs e)
{
Repeater r = (sender as TextBox).Parent.Parent;
}
My assertion, however, fails, and even if I get aLabel.Text , it ends up being an empty string, since r.DataSource is null (despite the fact that in the ItemDataBound event of aGrid, I already bound the repeater to a data source). After some debugging, I noticed that Repeater r is not the same repeater as the one that I bound in the ItemDataBound event of aGrid, but how could that be? In the ItemDataBound event of aGrid, I do the following...
<br />
e.Item.FindControl("aRepeater") as Repeater;<br />
...which I assume should be equivalent to...
(sender as TextBox).Parent.Parent;
Sorry for the long post.
|
|
|
|
|
I hired a coder to take my access db to mssql db with asp.net forms. He is no longer in the
picture and I am getting errors when one of my forms generates an email.
I think I have isolated the part of the code with the problem, but please answer as if I am an idiot,
because in this area, I am. TIA
I get this error: Unable to read data from the transport connection: net_io_connectionclosed
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) If Me.ChangedLabel.Text = "Yes" Then Dim mailer As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient() If debug = False Then mailer.Send("registration@lmhsc.org", "EnrolleeUpdates@lmhsc.org", _ HttpContext.Current.User.Identity.Name &amp; ": this user has made changes to class registration for the " &amp; SessionNameLabel.Text &amp; " session.", _ "The above user has just registered for a new class. The " &amp; Me.FamLastNameLabel.Text &amp; " family has changed " &amp; numadded &amp; " student record(s).") Else mailer.Send("registration@lmhsc.org", "EnrolleeUpdates@lmhsc.org", _ HttpContext.Current.User.Identity.Name &amp; ": this user has made changes to class registration for the " &amp; SessionNameLabel.Text &amp; " session.", _ "The above user has just registered for a new class. The " &amp; Me.FamLastNameLabel.Text &amp; " family has changed " &amp; numadded &amp; " student record(s).") End If End If
--------------------------------------------------------------------------------
|
|
|
|
|
I'm afraid that hiring people via rentacoder almost always ends this way.
bjh29 wrote:
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs)
If Me.ChangedLabel.Text = "Yes" Then
Dim mailer As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient()
If debug = False Then mailer.Send("registration@lmhsc.org", "EnrolleeUpdates@lmhsc.org", _ HttpContext.Current.User.Identity.Name & ": this user has made changes to class registration for the " & SessionNameLabel.Text & " session.", _ "The above user has just registered for a new class. The " & Me.FamLastNameLabel.Text & " family has changed " & numadded & " student record(s).") Else mailer.Send("registration@lmhsc.org", "EnrolleeUpdates@lmhsc.org", _ HttpContext.Current.User.Identity.Name & ": this user has made changes to class registration for the " & SessionNameLabel.Text & " session.", _ "The above user has just registered for a new class. The " & Me.FamLastNameLabel.Text & " family has changed " & numadded & " student record(s).")
End If End If
Sending an email in the page unload seems a bit odd to me. I mean, I am not even sure what the control state would be at this point.
1 - You have a control called ChangedLabel and the text needs to be Yes, in that casing, yes and YES will fail. Is this right ?
2 - you have a debug flag in the program, if it's set to true, then the mail won't send.
3 - I don't see any code that sets up the mail server, so I don't think this code would work.
4 - the email addresses are all hard coded, as is the message, making it harder to change them later, this is an example of the terrible quality of work you get when you pay someone in India peanuts to do a job, especially if you're clueless about development, an Indian team needs a firm and experienced hand to keep them in line and make them deliver a decent product, or at least one that's in line with the spec. This is not because they are Indian, it's because they are remote, and usually under experienced. The same would happen if you were in New York and hired first year students in LA, which is, in essence what you probably ended up doing.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Let me clarify....I was very happy with the stateside coder. I released him from the project, thinking I had found the bugs. The project has been up and running for some time now.
In response to your list:
1. The users must click on a an agree button, so I believe this is the Yes...no option of yes or YES
2. so if I just make the debug to true, I can bypass the email sending until I figure this out?
3. The mail server set up is in my web.config file
4. The email being sent is notifying me when users enter info into my db, hence letting me know when I have accounts to process.
|
|
|
|
|
1 - sure seems strange to me, you're checking the text on a control, that seems a round about way to check if a button was checked.
2 - If you make debug true, then the email object is still created ( inefficient, but it won't break anything ) and the email just won't send. Isn't the email not sending your issue ?
3 - you can do that, and it automatically configures the server when you create the object ? OK, I didn't know that
4 - If I were you, I would set up a table in the DB that does this, you could still send an email, but then you can check the DB and it will tell you what users have entered data. I would always have a backup, in case an email is lost.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I am sorry. I was not clear. It is generating emails, actually a LOT of them. It seems one is generated each time a text box updates.I get emails telling me 0 records are changed and one each time a record is changed. My problem is intermittent. About every 10 entries or so, I get the error. Perhaps if I could lesson the amount, it wouldn't error???? Could my mail server be overloading?
1. I could be wrong on what that is doing
2. What happens to the email created if it doesn't send?
3. OK
4. Hmm...will have to hire some help if I go that route.
Thanks
|
|
|
|
|
2 - there is no email sent if that setting is true. Only the object used to send mail is created
The place you're doing it is just silly. It is sent whenever the page unloads. The fact you get them when 0 records are changed, means the check if a controls text is Yes is not working. The code is either wrong, or the way it's being tracked, is a hack. The place to do this is an event handler for when the records are changed. If you send an email at all, it should be in the same code that saves a new record. Overall, I think you should be storing records in your DB to say that changes have occured, and perhaps have a windows service that once a day checks for rows that tell it updates occured, and send you one email to tell you a summary of changes for the day.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
That's above my head. I guess I will have to look at paying someone else to write some more code Since this is for a teeny non-profit, I may have to just turn off the email notice for now.
Thanks
|
|
|
|
|
bjh29 wrote: Page_Unload
This shows the person who wrote this code had no idea about how ASP.NET page life cycle works. Page_Unload will be called each time when the page refreshes and if I remember correctly, it is one of the events executed when page rendering completes. BTW, why you need and email from this event?
|
|
|
|
|
The form is for class registrations. I wanted to know when students were registered for classes. This for a homeschool co-op It is a three step process. 1. The family registers (I get an email for this, which for now is sufficient), 2. A volunteer is entered (a family member). 3. students are entered into classes - this is the process which gives me intermittent headaches.
This is what I had asked for, now in hindsight, I should have asked for a daily summary. Many of the things I asked for in the project were due to my inexperience in this realm.
|
|
|
|
|
Hi,
************************
Beginner Question *
************************
What is the best way to create Master page layout in VS2008.
-> Using drag n drop feature
-> Using CSS and hand coding for ...
-> Using free template off the NET.
OR ANY OTHER EASY WAY OUT...
If using drag n drop feature then how can i create a table, separating header, footer, left side container and main container ?
If using CSS then is there any best way to know the exact size and width of the division. I mean in CSS we need to specify width and height but how do i know what size would fit the best or may be i am missing some easy step here. Please do let me know..
or if using free template then where can i find the best professional free templates as after googlin it i can find all the funky type of templates but i need professional.
Any help would be greatly appreciated.
cheers mate
aNdy
|
|
|
|
|
Never use the drag and drop, always just hand code. Sometimes you need to do some trial and error, but you end up in control of what code you end up with.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hello to everybody,
I have the following problem. How can I send a hyperlink e.g. www.qwertz.com&p1=ä (with German special character) to another site? It is important, that the ASP.Net site send the Query with special Character, because the other site understands utf8 (directly database call), and cannot convert html.encoding.
What can I do, I’ve try it with Response. Encoding = Encoding.UTF8, but when I look in liveHeader(Firefox) then the system send information in html encoding.
Who has a solution for this problem?
Thanks for any ideas.
|
|
|
|
|
|
I am curently working on asp.net application and her CMS system...
This is virtual directory of site:
application
and CMS have his own virtual directory here
application/admin
so my question is: can i access first application folders such as:
application/images
from CMS system which is located in virtual directory
application/admin
------------------------------------------------------------------------------------
I was trying this way:
Request.Files[0].SaveAs(Server.MapPath("../test.txt"))
But this way i should exit virtual directory and get error
"Cannot use a leading .. to exit above the top directory."
Any help or alternative solution appreciated! Thx in advance....
|
|
|
|
|
MapPath is assuming that you're starting at the top level, not at your current one. So, don't do the . thing, specify the full path.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
hello everybody..
i have to provide feature of live web conferencing in my website i have no idea how to implement will u all guide me..Thanks..
|
|
|
|
|
meghamaharshi wrote: i have no idea how to implement
You want to implement it ? or want to integrate with some third party Application.
|
|
|
|
|
Thanks for reply..
if we can implement then its good and if any open source available then thats better..
|
|
|
|
|