session not working in classic asp on iis server 8 - iis

My Session variable isn't initialising in classic asp webPages which is hosted on iis server 8,
I have already configured the Session properties in session state feature view as well as in the Debugging Properties of ASP section of IIS server 8,
please help me i m facing this problems after shifting my whole website from Windows server 2008 r2 with IIS7 to Windows server 2012 r2 with IIS8
on IIS 7 i haven't face any issue regarding this session variables initialiasation
any help,would be appriciated
Thanks in Advance

You need to enable session state under classic asp in IIS7/IIS8.
Open IIS Manager. Navigate to the site you are working on. On the right double click ASP. Click on Session properties + to show all options. Change enable session state to true.

I have a same problem.In my case website has no cookie. I do not use SSL certificate for my websie and exist <httpCookies requireSSL="true" /> code inside system.web section . after I change this to <httpCookies requireSSL="false" /> my problem solved.

Try this code to make sure the variables aren't being initialising:
dim i
dim j
j = Session.Contents.Count
Response.Write("Session variables: " & j & "<br>")
For i=1 to j
Response.Write(Session.Contents(i) & "<br>")
Next
The code above will show you if there is any variable being initialized and the content of each one.

If session state is ok in the IIS settings, check to make sure that you didn't use session.Abandon() because when this method is called, the current Session object is not deleted until all of the script on the current page have been processed. This means that it is possible to access session variables on the same page as the call to Abandon, but not from another Web page and not when you plan to transfer data between two pages by using the session object.

Related

edit web.config to pass parameters [duplicate]

I have an ISAPI DLL installed under a directory like:
c:\inetpub\wwwroot\emsserver\emsserver.dll
This is a Delphi RAD Server app.
In IIS Manager (Windows 10), under Root (computer name) -> Sites -> Default Web Site -> Emsserver, I have a handler set up to handle "*.dll" requests with that DLL. The end result is I can access the app like:
http://localhost/emsserver/emsserver.dll/some-action
That works fine. All good there, output as expected. But the URL isn't very end user friendly.
Question:
Using IIS Manager on Windows 10, how can I configure it so that I can access the application without the DLL portions of the URL? So, like "http://localhost/some-action"?
Seems like it should be a simple enough thing to do, but I'm not seeing how. I tried setting up a handler both in the root server entry in IIS manager, as well as for the 'Default web site', but neither did the trick. I haven't used IIS in 20 years (been almost exclusively Linux & Apache), so I'm a bit out of my usual neighborhood.
You can use url rewrite to achieve this. Download the module from here.
Here is the result of the rule.

HTTP Error 401.2 - Unauthorized with Error Code 0x80070005 with both IIS ans IIS Express

After attempting to configure IIS as a replacement for IIS Express, both stopped working and delivered the above error on deploying the .NET Core project in VS2019. According to IIS anonymous authentication is enabled, I also entered explicit user name and password as well as giving my user all rights to work with the project's directory. I restarted the IIS several times and re-created the pools and Pages, as well as repairing VS2019 in hope to get the IIS Express running again at least.
I have no idea what else I could do.
EDIT: I am using IIS10
Module
IIS Web Core
Notification
AuthenticateRequest
Handler
aspNetCore
Error Code
0x80070005
Requested URL
http://localhost:12345/
Physical Path
C:\inetpub\...
Logon Method
Noch unbestimmt
Logon User
Noch unbestimmt
You can try the following steps to solve your problem:
Right click on the project, go to properties.
Select the web, and then you will find a service setting
Change the project URL for other port, like http://localhost:44338/.
I was able to figure it out myself by now:
For some reason during setting up the IIS and IIS profile (accidentally or by some quirk of VS), the anynomous authentification setting was set to false. Which also affected the IIS Express to not work properly anymore. Simply enabled anonymous authentication resolved the issue for both.
Project Properties -> Debug -> IIS profile -> anonymous authentification: ✓

Why is ASP.NET Core MVC Identity authentication resetting with IIS Cache-Control?

I am using the standard Identity authentication set-up with ASP.NET core MVC. It has been working fine for a long time, but I recently added Cache-Control on the production IIS server. The app is intranet-only and updated regularly, so it was getting to be a major hassle needing to clear everyone's cache every time the app was updated.
The setting I changed is was adding
Cache-Control: max-age=30
to the Http response header.
After making this change, the Identity authentication will randomly "reset" itself. For example, a user will log in successfully; they will then navigate to a page which is protected by Identity authentication. After doing so, the user is redirected back to the login page. This can repeat an arbitrary number of times before the user is finally able to make it to the desired destination page.
The worst part is, I cannot replicate the issue in any repeatable manner. I have witnessed it multiple times, but it doesn't happen 9 times out of 10 and I can't see any reason why it happens to begin with.
Does anyone know how Cache-control affects Identity authentication?
For cache issue, you could use iis HTTP header keep alive option.
you could follow the below steps:
1) Open IIS Manager and select the site from the connection pane.
2)Double-click on the HTTP Response Headers
3)Click Set Common Headers… from the action pane:
4)Check the Enable HTTP keep-alive checkbox, Check the box to expire Web content and set your time.
the main reason behind to use the keep-alive connection header to keep our HTTP requests open. This will avoid the need to repeatedly close and open a new connection.
or
you could use application pool recycling, iis output cache setti9ng.
1)From IIS, select the website.
2)Open “Output Caching” feature.
3)Click “Add…” from the Actions panel.
4)Specify an extension, Check “User-mode caching” and “Kernel-mode caching” and select the “Prevent all caching” options under each section.
5)Click OK.
6)now select Edit Feature Settings from the action pane in output cache window.
7) Uncheck Enable cache and Enable kernel cache.
8)Restart the website.

IIS gives localhost URI instead of server name

IIS7 serving .Net web application (simple database site).
I have a weird issue where the backgroundimage(URL) property of a element will be served as "http:\localhost" instead of "http:\servername". This is a problem because when a user connects to my site, "localhost" would be their workstation, not the IIS server. So the image (in this case a button) is blank.
The issue is intermittent, recycling the application pool seems to fix the issue for a time and then it comes back. IIS server also runs a SQL instance which eats ~28/36GB RAM.
Anyone ever seen anything like this?
In order to fix this you need to search for all locations where "http:\localhost" is hardcoded in your web app and replace it with a dynamic path. Even though localhost can work in your code if it is relative to the server, there are times when it will not work, such as in a link. You should get in the habit of never hardcoding your urls.
If you are using MVC -
value = Url.Content("~/Images/MyImage.png");
If you are using Forms -
value = ResolveUrl("~/") + "Images/MyImage.png"
Or relative pathing -
value = "~/Images/MyImage.png"

Form authentication works on dev server but not on IIS

We have a similar problem. We have a web application running under default appdomain. It was working fine until a week before...Suddenly it has encountered a problem. Below message is taken from event logs.
Event code: 4005 Event message: Forms authentication failed for the request. Reason: The ticket supplied has expired.
Application uses FormsAuthentication and gets the roles from aspnetdb.. After the error, when user logins to the page, it does not redirects to the default.aspx. Again login.aspx comes up. On the other hand application works fine on development server(localhost), but not on www(IIS 6.0).
Does any one has an idea?
Thanks,
İlknur
It looks that when Application Pool your app is running on is in Integrated Managed Pipeline Mode, which is default under IIS 7, you will need to add
<system.webServer>
<modules>
<add name="FormsAuthenticationModule" type="System.Web.Security.FormsAuthenticationModule" />
To configuration.
Please refer to [Performing Forms-Based Authentication and URL Authentication on Static Files with IIS 7] section from this article
Initially I added aforementioned section to web.config by hand, but IIS complained with runtime error, so I ended up using MMC panel for IIS (inetmgr) to add it via GUI. Application's config file wasn't modified, but feature started to work, so I'm not sure which configuration file GUI tool applied the change to.

Resources