How does IIS server handle requests concurrently?
I'm from C background, for a concurrent server written by C, when there is a new incoming request, the server program either spawns a new child process or a new thread to service the client. So if there are 10 users requests the index.html page at the same time, it could be 10 child processes generated on the server side, or 10 worker thread are used if the server is based on pre-threading worker thread pool.
But for asp.net web application(let's talk about asp.net not asp.net core who doesn't use Appdomain), below is my question:
Q1-IIS that hosts application will create a new Appdomain for the asp.net web application, but will a new Appdomain created to handle a new request? so if there are 10 requests then there will be 10 Appdomains being created? If not, how does IIS handle concurrent requests from multiple users?
Q2- What's the relationship between Appdomain and the worker thread in the CLR thread pool? does a new worker thread is used to run the application in the new Appdomain?
See also questions close to this topic
-
How to conditionally transform a sequence in linq/functional
There are many ways to do it, I want to do it using "Functional" approach and I do not want to do a procedural foreach loop.
My problem is simple, I have a sequence that I need to take and turn it into a new sequence of the same object with only some objects transformed while others staying intact.
I am adding this question because Linq doesn't have any inherent way of doing this (or does it?) I am hoping to have some good discussion on how many other ways this can be done.
Here is one way I can think of it, which is to create my own Linq "Operator"
WhenAny
public static class EnumerableMixins { public static IEnumerable<T> WhenAny<T>(this IEnumerable<T> source, Func<T, bool> predicate, Func<T, T> transformation) { return source .Select(x => { if (predicate(x)) { return transformation(x); } return x; }); } }
I can simply do
// Write a program that changes a sequence so that all ODD numbers become their next even numbers // var array = new [] {1, 5, 10, 15, 33, 55, 60, 62, 91}; var newArray = array .WhenAny(n => n % 2 != 0, n => n + 1) .ToArray();
This is working and it is functional. Is there any other way? (no for/foreach please)
-
C# MVC ASP.net ,facing slowness in loop task after time of starting
when i create any function that have to read from excel and then do some algorism on the data then write the result in the database ,
in the start of excitation the loop is working in very fast time ,but after a while it git slow and slow ,
please i need help .
-
Azure - Error CS0433: The type 'IAsyncDisposable' exists in both 'Microsoft.Bcl.AsyncInterfaces,
I've added the IAsyncDisposable interface to one of the classes of my project. Everything works fine when using Visual Studio. I can compile and execute the application without any errors nor warnings.
But after committing the project to Azure and compiling there I get the following error:
##[error]Eraltech.ConteoLive.Web\Services\HubEventService.cs(13,41): Error CS0433: The type 'IAsyncDisposable' exists in both 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' and 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' D:\a\1\s\Eraltech.ConteoLive.Web\Services\HubEventService.cs(13,41): error CS0433: The type 'IAsyncDisposable' exists in both 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' and 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [D:\a\1\s\Eraltech.ConteoLive.Web\Services\Eraltech.ConteoLive.Web.Services.csproj] Done Building Project "D:\a\1\s\Eraltech.ConteoLive.Web\Services\Eraltech.ConteoLive.Web.Services.csproj" (default targets) -- FAILED. Done Building Project "D:\a\1\s\Eraltech.ConteoLive.Web\Client\Eraltech.ConteoLive.Web.Client.csproj" (default targets) -- FAILED. Done Building Project "D:\a\1\s\Eraltech.ConteoLive.Web\Eraltech.ConteoLive.Web.sln" (default targets) -- FAILED.
The code I've changed is as follows:
public class HubConnectionService : IAsyncDisposable { ... public async ValueTask DisposeAsync() { if (HubConnection != null) { await HubConnection.DisposeAsync(); HubConnection = null; } } }
Any ideas on what is going on?
Thank you.
-
how to get all controls of aspx page without running in browser
I have aspx page which may controls. I want get all controls of aspx page without running into browser. Means by taking physical path, I want to get list of all controls from aspx.
for example - I have following aspx page and I want to get all controls(textbox and label) and their attributes.
<%@ Page Title="Home Page" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %> <asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </asp:Content>
-
Solution for contenteditable="true" property is not working for image tag when resize image in Chrome and Firefox
I want to resize the image inside the img tag in a div. I am using contenteditable="true" property for the div. I am editing the content but I do not select the image and resize the image in chrome and firefox
my code is simple
div contenteditable="true" img src="img.png" div
This code is working in the IE browser and I am selecting an image and also resize the image but in chrome and firefox, it won't work for me.
Please give some solution. Thank you
-
Use current Identity user ID with AutoMapper in .NET 5
I would like to know how I can access the current user ID inside AutoMapper when using Identity Framework.
{ public class MovieDto { public int Id { get; set; } public string Name { get; set; } public bool HasLiked { get; set; } // indicates if the current has liked the movie ... } }
I would like to be able to access
ClaimsPrincipal
from inside AutoMapper profile, for example:CreateMap<Movie, MovieDto>() .ForMember(dst => dst.HasLiked, opt => opt.MapFrom(src => src.UserLike.Any(ul => ul.UserId == User.FindFirst(ClaimTypes.NameIdentifier)?.Value));
Is it possible to achieve that with AutoMapper?
If that is not possible or not indicated, what should I do perform such query in my repository in a reusable way?
-
Remove Certain AppPool based on input Array in Powershell
I am trying to display whether the AppPool for IIS is started or not. By default it will display all AppPool State.
But if a parameter -EA (--exceptionAppPool) is passed while running the script it will not consider the status of those AppPool.
I am somehow stuck with the else{} statement when -EA is passed. Not sure how to remove the list of array passed in -EA from being considered in Get-WebAppPoolState method
param([String[]]$EA) if (-Not ($ParamAvailable = $PSBoundParameters.ContainsKey('EA'))){ $ApplicationPoolsState = Get-WebAppPoolState | % { return @{($_.itemxpath -split ("'"))[1]="$($_.value)" } } | % getEnumerator | % { if ($_.value -ne "Started"){ $statuses.critical += $_.key } else{ $statuses.ok += $_.key } } } else{ #----I want to exclude the Keys which is present in -EA array ? #----The example of -EA is .NET v4.5,.NET v4.5 Classic,DefaultAppPool }
script will run like .\check_appPool.ps1 -EA .NET v4.5,.NET v4.5 Classic,DefaultAppPool
How do I exclude those from being checked in the else statement
-
Invoke-RestMethod PUT from remote computer results in Error 500 with Flask api
I recently deployed my first Flask app using IIS on Windows Server 2019 with wfastcgi.
I'm able to see the website on http:myServerIP:88/, log-in and everything else works. I'm also able to see some JSON data output when accessing some GET routes from remote systems.
However, whenever I try to run
Invoke-RestMethod
from remote computer, which collects some information and calls the URL of the route of my website to update the info to MongoDB on server, it shows the error 500:Invoke-RestMethod : 500 Internal Server Error Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
At C:\Users\wk14\Desktop\update2DB.ps1:401 char:8- $res = Invoke-RestMethod -Method 'Put' -Uri $url -Body (ConvertTo-Jso ...
- CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
- FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
I've tested out the PUT route of my app by hosting it on Flask's dev server, and have the remote computer save its JSON data to a text file, then call the
Invoke-RestMethod
on my host, and it was able to update the data to MongoDB without issues.But after deploying the Flask app on IIS, the PUT route just stopped working with the error 500 on remote system.
I've tried looking around in the IIS manager, but still couldn't figure out what the issue is.Could someone please give me some guidance? Thank you!!
- $res = Invoke-RestMethod -Method 'Put' -Uri $url -Body (ConvertTo-Jso ...
-
URL redirect in IIS fails. ERR_TOO_MANY_REDIRECTS
I've tried to make this URL redirection work and already spent a whole day but couldn't get it to work. I've looked at a lot of resources on SO, Microsoft docs and IIS but couldn't find a fix.
I have a website called https://www.mywebsite.com (renamed) which is my base URL.
What I would like is when people hit that site they be redirected to https://www.mywebsite.com/sites/mysite/mypage (this is on SharePoint, not that it should matter for redirection purposes).
This is what I have in my
web.config
<rewrite> <rules> <rule name="Redirect to Sharepoint site" patternSyntax="ECMAScript" stopProcessing="true"> <match url="(.*)" ignoreCase="true" /> <conditions logicalGrouping="MatchAll"> <add input="{HTTP_HOST}" pattern="^www\.mywebsite\.com$" /> <add input="{HTTP_HOST}" pattern="^www\.mywebsite\.com\/sites\/mysite\/mypage$" negate="true" /> </conditions> <action type="Redirect" url="https://www.mywebsite.com/sites/mysite/mypage" appendQueryString="false" /> </rule> </rules> </rewrite>
The problem is I get is ERR_TOO_MANY_REDIRECTS. The first time user hits the base URL both the conditions are true and it gets redirected to https://www.mywebsite.com/sites/mysite/mypage, however, after the first redirect, the second condition in the rule should evaluate to false and no further redirects should happen.
Any help is greatly appreciated.
-
C++/CLR linking a static library to a dynamic library
I am trying to link two libraries together. One is a dynamic library, the other is a static library. They are both compiled with /clr /MD.
I want to reference the static library inside the dynamic library. So I added the static library as a reference to the dynamic library.
As a POC the static library only has one class + function:
// PacketCommunicationX.h: #pragma once using namespace System; namespace PacketCommunicationX { public ref class PackX{public: void MyFunc(); }; } // PacketCommunication.c: #include "PacketCommunicationX.h" void PacketCommunicationX::PackX::MyFunc(){}
The dynamic library only has one free function:
// Source.cpp: #include "PacketCommunicationX.h" void Func(PacketCommunicationX::PackX^ r){ r->MyFunc(); }
When I compile the dynamic library I get the following error:
1>Source.obj : error LNK2020: unresolved token (06000001) PacketCommunicationX.PackX::MyFunc 1>*path*\Release\UsePackX.dll : fatal error LNK1120: 1 unresolved externals
And I am at a loss to how and why this is happening...
-
How to block enter in textbox?
How to disable the ability to create a new line by pressing enter in text box. When I clicked textbox and write something and press enter my text box makes newline
-
How to call void from another file?
How to make and call void from another file.
public: void powrot() { logt->Enabled = false; logt->Visible = false;}
This is void and i wanna make it in another file.
private: System::Void pow_Click(System::Object^ sender, System::EventArgs^ e) { powrot(); }