asp.net-3.5

How to catch HttpRequestValidationException in production

本小妞迷上赌 提交于 2019-11-29 01:15:20
I have this piece of code to handle the HttpRequestValidationException in my global.asax.cs file. protected void Application_Error(object sender, EventArgs e) { var context = HttpContext.Current; var exception = context.Server.GetLastError(); if (exception is HttpRequestValidationException) { Response.Clear(); Response.StatusCode = 200; Response.Write(@"<html><head></head><body>hello</body></html>"); Response.End(); return; } } If I debug my webapplication, it works perfect. But when i put it on our production-server, the server ignores it and generate the " a potentially dangerous request

Making a short URL similar to TinyURL.com

狂风中的少年 提交于 2019-11-28 19:44:52
I'm building a new web app that has a requirement to generate an internal short URL to be used in the future for users to easily get back to a specific page which has a very long URL. My initial thoughts are to store a number in a database and output it in a HEXADECIMAL value to keep it shorter than an integer. TinyURL.com seems to use something other than HEXADECIMAL (multiple case letters mixed with numbers). Is there an easy way to generate something similar what TinyURL does? Rubens Farias Please, check out this good explanation on subject: Random TinyURL Browser (Updated) . Important part

How the session work in asp.net?

☆樱花仙子☆ 提交于 2019-11-28 17:52:05
Please any one suggest me how the session is actually work in asp.net? I am confuse in part of session and want to briefly knowledge of it so please guide me ASP.NET uses a cookie to track users. When you try to write something to the session for the first time a cookie is sent to the client, something like ASP.NET_SessionId . This cookie is sent by the client on subsequent requests. Thanks to this cookie the server is able to identify the client and write/read the associated session data. It is important to note that this cookie is not persistent (wouldn't survive browser restarts) and is

LINQ to SQL — Can't modify return type of stored procedure

孤人 提交于 2019-11-28 17:13:20
问题 When I drag a particular stored procedure into the VS 2008 dbml designer, it shows up with Return Type set to "none", and it's read only so I can't change it. The designer code shows it as returning an int, and if I change that manually, it just gets undone on the next build. But with another (nearly identical) stored procedure, I can change the return type just fine (from "Auto Generated Type" to what I want.) I've run into this problem on two separate machines. Any idea what's going on?

Resources for learning LINQ?

社会主义新天地 提交于 2019-11-28 16:33:43
问题 I'm looking to learn LINQ, but I'm finding that there is a lot more to it then what I initally expected. In fact, there's so much that I'm not sure where is the best place to start. I know that there's LINQ to SQL, and LINQ to Entities, and a number of other LINQ whatevers out there. Which is the best to start with? It seems that I see more information readily available about LINQ to SQL, but I have seen quite a bit of information about LINQ to Entities also. Is LINQ to Entities more

CheckBox inside ListBox

烈酒焚心 提交于 2019-11-28 14:45:37
How to add checkbox inside the listbox. Where ChechBoxList controls is not good for more records, By using listbox user can easily scroll to choose the item. Geetha. Rob Cooper What you want is the CheckBoxList . Newer CheckBoxList Pretty nice step-by-step here . Asad Butt what about checkedListBox ? <asp:CheckBoxList id="checkboxlist1" runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> </asp:CheckBoxList> To access items on user action void checkboxlist1_Clicked(Object sender, EventArgs e) { if (checkBoxList1

How do i specify wcf behaviorExtension class type without the assembly version number?

自作多情 提交于 2019-11-28 09:35:48
问题 I have a web app that uses a WCF service that utilizes a behaviorExtension like so: <behaviorExtensions> <add name="clientCredentialsExtension" type="Simon.Web.Giftcard.WCFSecurity.ClientCredentialsExtensionElement, Simon.Web.Giftcard, Version=1.0.3736.20411, Culture=neutral, PublicKeyToken=null"/> </behaviorExtensions> The problem is this web app's version changes with every compile (i think) and thus invalidating this entry. How can I avoid having to change the version number every time I

Access to the path Denied when uploading excel file

匆匆过客 提交于 2019-11-28 09:34:00
问题 When uploading an excel file I am receiving this error, can anyone help me? Access to the path 'C:\Data\IronElements\Upload\AUMData\20101202 031815.xlsx' is denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.UnauthorizedAccessException: Access to the path 'C:\Data\IronElements\Upload\AUMData\20101202 031815.xlsx'

GridView's NewValues and OldValues empty in the OnRowUpdating event

流过昼夜 提交于 2019-11-28 07:22:45
问题 I have the GridView below. I am binding to a custom datasource in the code behind. It gets into the "OnRowUpdating" event just fine, but there are no NewValues or OldValues. Any suggestions as to how I can get these values? <asp:GridView ID="gv_Personnel" runat="server" OnRowDataBound="gv_Personnel_DataBind" OnRowCancelingEdit="gv_Personnel_CancelEdit" OnRowEditing="gv_Personnel_EditRow" OnRowUpdating="gv_Personnel_UpdateRow" AutoGenerateColumns="false" ShowFooter="true" DataKeyNames=

WCF WebServiceHostFactory MaxReceivedMessageSize configuration

拥有回忆 提交于 2019-11-28 06:50:10
问题 I have a RESTful WCF web service called "Palladium" as a project in my VS2008 solution. It is hosted in an ASP.Net 3.5 Web Application using the WebServiceHostFactory implementation via a page called "Palladium.svc". My service works in a manner similar to the one explained here, whereby POSTs can be received by the service along with other parameters as defined in the URITemplate. The service works well, and I can receive posted information and work with it. My problem occurs when the post