Can someone explain me what is is the relationship between App Domain and thread? msdn says "threads are free to cross application domain boundaries; a new thread is not created for each application domain." suppose there is one thread t inside Appdomain a1 .there is an another App domain a2 .thread t can cross to a2 from a1 means it can access a2 memory area If thread can cross the app domain boundaries share the memory space then how application domain isolation is still there?
I want to load data to my application domain using a thread so it will be executed at all times. How can I achieve this? I want the thread will start when iis starts and terminate when iis exits.
Note:
I want to do this so I can use disconnected architecture in my asp.net application.
We have a ASP.NET site that partially depends on forms authentication for login credentials, however the implementation of IPrincipal is completely custom.
But, when running the site on a particular server (which is somewhat semi-hardened when it comes to security), the app crashes when invoking IPrincipal.IsInRole() with the following messsage:
System.SystemException: The trust relationship between the primary domain and the trusted domain failed.
This indicates a communication error between the web-server and the DC, however since our application doesn't at all utilizes Windows authentication, I don't see why it needs to communicate with the DC.
This is my implementation:
[code]...
EDIT:
I was finally enable to reproduce this error on my dev-machine (i revoked my machine from the DC yesterday, but didn't reproduce it until today)
HttpContext.User is actually a WindowsPrincipal by default it seems, and the error in my code was that I only replace it with CustomPrincipal upon login. Hence, unathenticated users still get the WindowsPrincipal which then fails horribly if you have trust issues on your AD.
I tried changing the default principal by invoking this on appstart
what is considered a many-to-many relationship in a domain model class ? I mean how to implement a many-to-many relationship in a domain model class ? In SQL this is represented by a link table between two table but how this is represented in a domain model driven application ?
I want to remove checked items from checklistbox (winform control) in class file method which i am calling asynchronously using deletegate. but it showing me this error message:-
Cross-thread operation not valid: Control 'checkedListBox1' accessed from a thread other than the thread it was created on.
i have tried invoke required but again got the same error. Sample code is below:
My feeling says it's not posible but anyway I am curious if there is at least a workaround for accomplish this.Basically I am working at my client site and my machine is not connected to the domain.What I want to do is running a web application locally under a domain account, and using the webdev server.The webapp uses the default authentication, windows authentication that is.I tried using impersonation with domainuser & password but I got the following error Could not create Windows user token from the credentials specified in the config file. Error from the operating system 'Logon failure: unknown user name or bad password.I have to mention that the username and the password are correct.
I have two domain servers X and Y.My Asp.net Web application is hosted on Domain X.But my scope is required to authorize the user of Domain Y on the Web application hosted on Domain X server.I am using Windows Authetication mode in application
i want a continously running thread in my web application for sending mail to admin if the logged complaint of the user in not solved by technician within 24 hours.
i am able to send mail to administrator
i just want a watch on database for unsolved issues with timespan of more than 24 hours and inform to administrator about the same
I maintain a ASP.NET web application that causes a user's network connection to reset for several seconds when it executes a procedure. Therefore, the page request times out on the user's end as they never receive the web application's response (the connection dies before it gets the response packet).
To resolve this situation, I was contemplating having the ASP.NET page execute an asynchronous function that incorporates a Thread.Sleep(5000); // sleep for 5 seconds before executing the connection reset This way, the browser has 5 seconds to receive the page's response before their connection resets.
I have concerns with using Thread.Sleep and asynchronous functions in ASP.NET though. I've never attempted to do it before, so I'm unsure of the potential problems it may cause. Does anyone see potential problems with starting an asynchronous thread that contains a Thread.Sleep in an ASP.NET application?
I don't know if it's IIS, ASP.NET or IIS7 related. I take a chance here, if you think I'm in the wrong forum, just tell me which one I should post to.
I have made the smallest demo project to illustrate my problem. You can download the sources
Here
Visual Studio 2008, .NET 3.5, IIS7, Windows 7 Ultimate 32 bits. The IIS Website is configured ONLY for Windows Authentication in an Integreated pipeline app pool (DefaultAppPool).
Here's the problem. I have an Asp.NET MVC 2 application. In an action, I start a thread. The View returns.
The thread is doing it's job... but it needs to access Thread.CurrentPrincipal.Identity.Name
BANG
The worker process of IIS7 stops. I have a window that says: "Visual Studio Just-In-Time Debugger An unhandled exception ('System.Object.DisposedException') occured in w3wp.exe [5524]"
I checked with the debugger and the Thread.CurrentPrincipal.Identity is valid, but the Name property is disposed.
If I put a long wait in the action before it returns the view, then the Thread can do it's job and the Identity.Name is not disposed. So I think the Name gets disposed when the view is returned.
For the sake of the discussion, here's the code that the thread runs (but you can also download the demo project. The link is on top of this post):
I'm new to threading and have used it successfully, but limited. I can spawn a thread and have the main thread reference variables in the spawned thread, but I don't know how to allow the spawned thread to reference (and update) variables in the main thread.
Any example threading code I've seen on the web appears to be WAY more complicated than what I do, so I am unable to understand or integrate into my code.
I want to start a new thread to query a database while my web application continues running. I was under the impression that by using threads I can run the querying process independently while the normal web application page cycle carries on, but I could be wrong.
public class DbAsyncQuery { Dictionary<string, object> serviceResults = new Dictionary<string, object>(); public void UpdateBillingDB() { QueryAllServices(); foreach (KeyValuePair<string, object> p in serviceResults) { IEnumerable results = (IEnumerable)p.Value; IEnumerable<object> sessions = results.Cast<object>(); DbUtil.MakeBillingDBEntry(sessions, p.Key); } } public static string[] servicesToQuery = new string[] // Must go in config file ultimately { "xxx.x.xxx.xx" }; public delegate void Worker(); private Thread worker; public void InitializeThread(Worker wrk) { worker = new Thread(new ThreadStart(wrk)); worker.Start(); } public void InitializeQuery() { Worker worker = QueryAllServices; InitializeThread(worker); } private void QueryAllServices() { Dictionary<string, DateTime> lastEntries = DbUtil.GetLastEntries(); foreach (string ip in servicesToQuery) { string fullServicePath = "http://" + ip + ":800/MyWebService.asmx"; //object[] lastEntry = new object[] { lastEntries[ip] }; object[] lastEntry = new object[] { new DateTime(2011, 1, 1, 0, 0, 0) }; object obj = WebServiceHandler.CallWebService (fullServicePath, "MyWebService", "GetBillingDBEntries", lastEntry); serviceResults.Add(ip, obj); } } }
It seems to basically stall and wait to finish the query before loading the page (which can be thousands of rows, so it takes awhile). I put this in the following section of Global.asax:
This is one of my first web pages, and I'm new to threading. I understand there is a difference between creating your own thread and using the ThreadPool. In this method, I am using my own thread, I think. Not sure if that's the best way. The querying process can be completely independent, and its only going to occur on scheduled intervals (every 8 hours or so). The user doesn't need to have up to the minute data, so it can take awhile. I just don't want the site to wait for it to finish, if that's possible.
I need to call a function everytime a visitor visits one of my website's page. But I do not want the execution of the function to interfere with the interface between the user and the website i.e. different thread. What is the best way to do that on ASP.Net?
lock (this) { if (!isGoodPassword) Thread.Sleep(2000); } I would expect that this would allow all correct passwords without stalling, but if one user enters a bad password another successful password from a different user would also be blocked. However, the lock doesn't seem to lock across ASP.NET threads.
I want a example of multithreading .i want to use it in a web form not on console.i am using C#.net .and how to use thread.sleep method for a particular thread.
I need little clarification regarding the Application Domain. As it has been said in the .net framework documentation "a process can have one or more application domain", Does it means There can be only one process in a machine dedicated for the .net application and whenever a new .net application gets executed, an application domain gets created in the above mentioned process?
I have developed web application using asp.net 3.5 ,c# 3.0 and visual studio 2008,sql server 2005. i have created .msi file to deploy application on server.. now for testing purpose running in lan for that i want give url name eg.now i'm accessing from LAN like this
I'm going to publish an asp.net pre-compiled web site on shared hosting account but I don't want my code to be copied and able to run on another domain. I need to check domain and if not example.com or www.example.com redirect to error page or show error as response.
EDIT: Here is my solution based on given answers
void Application_BeginRequest(object sender, EventArgs e) { string[] safeDomains = new string[] { "localhost", "example.com", "www.example.com" }; if (!((IList)safeDomains).Contains(Request.ServerVariables["SERVER_NAME"])) { Response.Write("Domain not allowed!"); Response.End(); } }
I have two web applications in ASP.NET which are quite the same (same business logic, same DAL, same DB scheme but different instance).
The only thing that I need to change is the design (logo, color,...) and the text (global and local resource) to adress two separate business sector. We cannot "subdomain" the application because we need the two app "seems to be" independant.
Is it a good idea to run only one instance for the 2 web applications.
For example :
I will have 2 hostnames : mycompagny.com and mycompagny2.com and I will put an HTTP Module which will set a string which will be propagated in my application like 'company' and 'company2'. I will instanciate the dal only once but the connection string will change depending on the string 'company' or 'company2'.
Just for information it is a Multi-Business and Multi-Tenant application because both application will have custom theme for some parts of the application.
For example :
mycompagny.com/Busineess1, mycompagny.com/Busineess2, mycompagny.com/Busineess3,.. and mycompagny2.com/Busineess2, mycompagny2.com/Busineess2, mycompagny2.com/Busineess3,...
I have a simple question but I still a bit confused after googling. The situation is like this. I have ASP.NET deployed in a Web Server, and had set to a Web Garden and IIS Worker Process is more than 1. So I would like to ask, is it all worker processes running under same Application Domain? Or can said Web Garden running under same Application Domain?
We have an application gathering counter statistics and we would like the values to reset after executing the iisreset command and that's all.
Microsoft says Application_Start is:
Called when the first resource (such as a page) in an ASP.NET application is requested. The Application_Start method is called only one time during the life cycle of an application. You can use this method to perform startup tasks such as loading data into the cache and initializing static values.
However, these are resetting at unexpected intervals. What determines when the application domain's life-cycle ends and this method is called on the next request?