Hi everyone, here is my question: I've a hosted web application (no IIS access, I can only modify Web.config). What I want is that when someone request a resource like this: http://somewhere/some\_non\_existing\_path/bar.gif (where the directory "some_non_existing_path" doesn't exists!) .NET executes a class made by me (say MyClass.cs). I've tried with something like this: but I got the 404 error... How can I do that ?? Thank you in advance ;) ---------------------- !happy coding!
sgatto159
Posts
-
Fake image url -
Automatic Letter generationIf your users have Word2003, you can use native Word XML. In Word, save your template in xml with the name template.aspx. Add the file to the project, scriplet-it so that fields became value expressions (something like <%=emplName%>). Set content type to "application/msword" and the content-disposition to "attachment; filename='letter.doc'" hope this helps ;) ---------------------- !happy coding!
-
Regex.Replace hangs !!!Hi all, I'm trying to write some sort of forum with "forumcode" like snitz. To quote some text, user can surround it with [quote]...[/quote]. To do this I have written this regex:
@"(?<quo_iniTag>\[quote\])(?<quo_text>.*)(?<quo_endTag>\[/quote\])"
and the handler is something like this:
if(m.Groups["quo_iniTag"].Value.Equals("") == false && m.Groups["quo_endTag"].Value.Equals("") == false)
return "####"+m.Groups["quo_text"].Value+"###";But, sometimes (not always), it hangs forever on the method Replace. Can you help me please ? Thanks in advance ! ---------------------- !happy coding!
-
Page attribute & concurrencyleppie wrote:
You can just save object instances there that will be persisted for the current session of the user, which is porbably what you are looking for
Err... no. What I want is a method of passing objects between a class and it's subclass in a concurrent-access-safe-manner and only in the scope of a request/response (I need something like java's Request.setAttribute). ViewState is great, but IMHO only for intranet applications. But, if your answer is correct... I've found it. Thanks! ---------------------- !happy coding!
-
Page attribute & concurrencySo it does not do some sort of object pooling ? for every request it creates an object from that class, serve the request, destroy the object ? :wtf: well... ok, thanks! ---------------------- !happy coding!
-
Page attribute & concurrencyHi, what if I have a Page subclass A.cs with a protected attribute "foo" and I use it in A.aspx.cs ? what if many users request page A ? what value of "foo" will they see ? Class A:
public class A : System.Web.UI.Page { protected string foo; private void Page_Load(object sender, System.EventArgs e) { foo = "hi there " + Request["AUTH_USER"]; } ...
Page A:<%@ Page language="c#" Codebehind="A.aspx.cs" AutoEventWireup="false" Inherits="some.A" %> <%=foo%> ...
Thanks in advance for your reply -
Windows Forms: how to do automatic disposing? Here is my answer...Forget the garbage collector (comment that line). I've posted that snippet to share with the community this idiom of disposing components in C# Windows Forms applications. Hope this clarify the topic of this post. Thanks however for the suggestion (as I have already said, I am new to C#)
-
Windows Forms: how to do automatic disposing? Here is my answer...I will read that (I' quite new to C#), but I don't like C++ ;)
-
Windows Forms: how to do automatic disposing? Here is my answer...Second version:
public static void disposeComponents(Component f, bool disposeForms) { foreach (FieldInfo fieldInfo in f.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic)) { object value = fieldInfo.GetValue(f); if(value is Form && disposeForms == false) continue; if(value is Form && f is Form) { if( ((Form)f).ParentForm == value ) continue; if( ((Form)f).MdiParent == value ) continue; } if(value is IDisposable && value != null) { ((IDisposable)value).Dispose(); fieldInfo.SetValue(f, null); } } System.GC.Collect(); }
-
Windows Forms: how to do automatic disposing? Here is my answer...Hi all, here's a question for you. What if one needs to do automatic disposing of a form's components when it is closed ? And what if one wan't write Dispose() for each component ? Here is my answer, I hope you agree is correct. I tested it in win2k/winXp with taskmanager and I have seen this piece of code effectively release the memory when the form is closed. Suggestions are really appreciated.
/* Here f is the Form. This method is to be called in the Dispose method of the subclass of your Form. */ public static void disposeComponents(Component f) { foreach (FieldInfo fieldInfo in f.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic)) { object value = fieldInfo.GetValue(f); if(value is Component) { ((Component)value).Dispose(); fieldInfo.SetValue(f, null); } } System.GC.Collect(); }
-
The object is currently in use elsewhereHi all, I'working on a windows form c# mdi application. Sometimes (I can't reproduce the situation) I got a "The object is currently in use elsewhere". All I can tell is that it always happens in front of a gui event (form closing, form resizing, form activation and so on...). Does anyone know what the problem can be ? Thanks
-
How to Use DropDownList in ASP.NEThum... 1- if that snippet is in a codebehind, than your class inherits from
System.Web.UI.Page
which does not containsSelectedItemCombo
). So the question is: what isSelectedItemCombo
? 2- doing sql like that in callbacks is a bad idea 3- doing sql withouttry{}catch{}finally{}
is even worst 4- replace while(thisReader.Read()) with: if(thisReader.Read()): is less confusing. But: why notDataSet
? 5- replaceif(strID == this.DropDownList1.SelectedValue.ToString())
withif(strID.Equals(this.DropDownList1.SelectedValue.ToString()))
hope this helps -
having filefilter problemWrite a method like this:
public void findFiles(string where, bool recurse, params string[] what){ /*...*/ }
so you can invoke without arrays:findFiles("c:\\", true, "*.mp3", "*.avi"); findFiles("d:\\", false, "*.mp3");
and so on. hope this helps -
Regular Expressionhope this helps (go to "Validating Unicode Characters"): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/paght000004.asp[^]
-
having filefilter problemI think second parameter is a simple pattern, not a regexp. You can't do things like *.mp3|*.mpg
-
How to Use DropDownList in ASP.NETwhere is your databind() ? in page_load ? if I understand your problem, I'm quite sure you've not checked if ispostback before databind(). try (in Page_Load):
/* ... */ if(IsPostBack == false) { /* ... */ DropDownList1.DataBind(); } /* ... */
-
Dealing with dpiI don't see why not. Infact, I've found how to do it:
g.PageUnit = GraphicsUnit.Millimeter; g.DrawRectangle(Pens.Black, 50, 50, 50, 50);
does exactly what I need: without care of dpi draws in inches/millimeters/whatever. -
Dealing with dpiHi all, can someone post a snippet of code that draws a rectangle of 2x3 inches ? I mean something that on every Graphics (and then with every sort of dpi) is 2x3 inches. I'm getting mad whit this.... please help ! thanks.