asp.net

ASP.NET application architecture: bet practice for lenghty background processes?

I'll try to be brief. What is the best practice for calling a routine from an asp.net web application that initiates a lengthy 'background' process that must be run? For example, I want to click a button on my webpage that says "Run data conversion" (for example). This data conversion routine may take 20-40 minutes to run, so it seems...

ASP.NET: Best way to restrict access by IP address

For an ASP.NET C# application, we will need to restrict access based on IP address. Edit: I liked @Mitch Wheat's answer. Will use this in our implementation. Thanks. ...

C# Reflection: Getting the fields of a DataRow from a Typed DataSet

I am currently building a method that takes an object that is of type DataRow from a typed DataSet, and then returning a string in JSON format of the fields in the DataRow (for use in a Web Service). By using System.Reflection, I am doing something like this : public string getJson(DataRow r) { Type controlType = r.GetType...

How can I take more control in ASP.NET?

I'm trying to build a very, very simple "micro-webapp" which I suspect will be of interest to a few Stack Overflow'rs if I ever get it done. I'm hosting it on my C# in Depth site, which is vanilla ASP.NET 3.5 (i.e. not MVC). The flow is very simple: If a user enters the app with a URL which doesn't specify all the parameters (or if an...

GridView with Pager TopAndBottom

Hi I have extended the standard GridView control in ASP.NET. Basically it is just the same, but paging and sorting is done using callbacks. I have successfully created my own PagerTemplate, but it only works when PagerSettings.Position is set to Top. I want to have the pager at both the top and the bottom. I get an HttpException sayin...

How to deploy web app directly from Visual Studio 2008?

I used to use discountasp.net and I can use Visual Studio 2008 to "publish" the website directly to the web host. I am using a dedicated server now (well, to be exact, Amazon EC2 Windows), how should I setup the web server so I can deploy the website directly from VS 2008? I tried to setup a FTP server but couldn't get it working. Thank...

ASP.net: Display PDF in a asp.net web page

User click on a link button and it will direct them to a url that is dynmaically generated which a pdf file. The browser will prompt the user to either save or open it. I want to know if it is possible to downlaod the pdf file to the server then show the pdf file in the asp.net web page. When i google on this question, 99% of top link a...

How can I hook into the current FormsAuthenticationModule in a Medium Trust environment?

I've got an HttpModule in my application that hooks into the FormsAuthenticationModule's Authenticate event with the following code: public void Init(HttpApplication context) { FormsAuthenticationModule faModule = (FormsAuthenticationModule)context.Modules["FormsAuthentication"]; faModule.Authenticate += new Form...

Asp.net Request.Browser.Crawler - Dynamic Crawler List?

I learned Why Request.Browser.Crawler is Always False in C# (http://www.digcode.com/default.aspx?page=ed51cde3-d979-4daf-afae-fa6192562ea9&article=bc3a7a4f-f53e-4f88-8e9c-c9337f6c05a0). Does anyone uses some method to dynamically update the Crawler's list, so Request.Browser.Crawler will be really useful? ...

On a Silverlight 2 datagrid, how can I get a collection of only the rows that are edited?

I load data into my grid using a WCF service. When a user clicks 'Submit' on my silverlight 2 control, I want to send only the edited rows back to my WCF service for updating. Is there a good way to do this? ...

New line in GridView cell

I'm binding a GridView to an LINQ query. Some of the fields in the objects created by the LINQ statement are strings, and need to contain new lines. Apparently, GridView HTML-encodes everything in each cell, so I can't insert a <br /> to create a new line within a cell. How do I tell GridView not to HTML encode the contents of cells? ...

Line counter for ASP.NET

I know the number of lines of code is completely arbitrary and a horrible metric. Even so, after a long day I like to click a little button and see that my pet project grew by 10%. (Or if I spent the day refactoring yet again it slimmed down by 10%, woohoo!) I've used two line counters that can analyze code from CodeProject in the past,...

Should I return IList or List to the Controller in MVC ?

What is difference to the controller that gets the return with repect to rendering the List? In Linq dataContext: public IList<Response> GetResponses(int ID) { var responses = from r in this.Responses where r.ID == ID orderby r.Date select r; return responses.ToList(); } OR public List<Response> GetResponse...

When are ASP.NET MVC Controllers garbage collected?

Once a controller object is created when does it become available for garbage collection? ...

Asp.Net ViewState lost with RegisterClientScriptBlock

I am validating a zip code using Javascript that is generated server-side, and injected when a LinkButton is clicked. Then, I retrieve the return value by calling a server-side function when the page loads. This works nicely, but the problem is that the ViewState is completely lost after PostBack. Below is the code, starting with the p...

Using Autofac with ASP.NET and the MVP pattern

I'm trying to integrate Autofac into an exsisting ASP.NET web application. The pages follow the MVP pattern. Each page implements a View and delegate functionality to a Presenter. The View is injected into the Presenter thru the constructor. I was able to register the Presenter and View and the page loads fine but when a postback h...

Simple jQuery task failing: hide child elements of <div> tag

There has to be a simple explanation for this. I have a parent <div> tag containing a number of child divs that need to be hidden depending on their class. Problem is, I can't even seem to get a handle to my parent div. What on earth is the problem here? I'm going out of my gourd. The jQuery code (snippet) looks like this: $(functi...

Can I start with a string and instantiate an object of that string?

I am currently working with LINQ and C#. I have a DropDownList of the tables in my LINQ to SQL model. I want the user to be able to select a LINQ table name from the DropDown. In code I want to create an instance of that LINQ class and then run a Select or it or anything else I want. How would I accomplish creating the object based on...

How can I ignore case in a regex?

I have an ASP.NET RegularExpressionValidator that checks file extensions. Is there a quick way I can tell it to ignore the case of the extension without having to explicitly add the upper case variants to my validation expression? ValidationExpression="([^.]+[.](jpg|jpeg|gif|png|wpf|doc|docx|xls|xlsx ... ...

Data driven design problem - data counting

I want to provide about 10 different 'statistics' to my users. Each stat represents the count returned by a different query of my database. Each stat/query is specific to the current user. What is going to be the most efficient way to achieve this? Am I right to think that running the stat queries, for each user on each page of my site (...