Check the IIS virtual path in IIS 7.5 - asp.net

I am trying to encrypt some sections of the web.config file of one of my applications by using RSA encryption at user level.
So I followed all the steps listed in here and I succesfully created the provider and granted access to my application. However, I have some problems in specifying the virtual path for my application.
I run IIS 7.5 in a Windows Server 2008 R2. My application is called www.testsite.com and its ID is 4.
The aspnet_regiis tool is placed in the Windows\Microsoft.NET\Framework\[version] folder:
Therefore in order to encrypt the connectionStrings section I run the command:
aspnet_regiis -pe connectionStrings -app "[Application Path]" -prov "myRSAProvider"
I tried as [Application Path], the followings:
/W3SVC/4
/W3SVC/4/root
/W3SVC/4/root/www.testsite.com
/www.testsite.com
And I always receive the error
The configuration for virtual path '[Application Path]' and site
'Default Web Site' cannot be opened.
Failed to map the path '[Application Path]'. Failed!
I tried to browse many resources on the web but this IIS virtual path specification is not extensively covered. In IIS6 I could get it by running aspet_regiis -lk but this command does not work anymore in IIS 7.5. May somebody help?

You may be having two issues.
At the end of your command statement specify your site with the command -site "4" Also note that instead of the #4 you could write in your site name instead. e.g. -site "www.testsite.com"
aspnet_regiis -pe connectionStrings -app "[Application Path]" -prov "myRSAProvider" -site "4"
It is also very important that you run the command prompt as Administrator.
I had the same error you had running IIS 7.5 in a Windows Server 2008 R2 and this is what helped me.

Related

inno Setup 6, how to deploy a web application to local IIS 10 in Windows 10

I'm using Inno Setup 6 as an installer creator. I have an ASP.NET code that I need to extract on a local computer that is running Windows 10 and create a web application pointing to that extract on a local IIS 10.
I tried an answer from 10 years ago but that seems to be too old as it apply to IIS 6 and throws an exception in Windows 10.
I tried having Inno Setup script:
[Run]
Filename: "powershell.exe"; Description: "Deploy WebApi"; Parameters: "-ExecutionPolicy Bypass -File ""{app}\webapi\webapi_deploy.ps1 {app}\webapi"""; WorkingDir: {app}\webapi ; Flags: nowait postinstall skipifsilent
execute a powershell script:
New-WebApplication -Name "my-webap" -Site "Default Web Site" -PhysicalPath $webapiPhysicalPath -ApplicationPool "DefaultAppPool" -force
but the physical path does not pass from inno setup to the powershell script.
Is there an installer, Inno setup or other that deploys code to IIS as a web application?
Is there a way in Inno Setup to pass the extracted code path to the powershell script?

error 1002: 'LMW3SVC/1/ROOT/MyFirstWebsite' is not a well formed IIS metabase path

I am trying to learn how to deploy my first website which is physically located here (C:\Users\Amal\Documents\Visual Studio 2008\WebSites\ErrorHandlingTest). I am using instructions from some book. after installing the Internet Information Services on my laptop which has Windows 7 ultimate on it. I added a virtual directory and gave it the alias (MyFirstWebsite). after that I was able to open the website just by typing
http://localhost/myfirstwebsite/mypage.aspx
on the address bar of my firefox v.21 browser.
the book then told me to do some code compilation to the website by using the command-line tool named aspnet_compiler.exe which is supposed to compile my website into binary files after running this command :
aspnet_compiler -m W3SVC/1/ROOT/MyFirstWebsite C:\MyFirstWebsiteDeply
but I got this error:
error 1002: 'W3SVC/1/ROOT/MyFirstWebsite' is not a well formed IIS metabase path.
I use asp.net 3.5 , visual studio 2008 , internet information services version 7.5.7600.16385
Try
aspnet_compiler -m LM/W3SVC/1/ROOT/MyFirstWebsite -f C:\MyFirstWebsiteDeply
You had missed the "LM" at the start of the metabase path.
Actually the iispath should be /LM/W3SVC/1/ROOT/XXX.
Pay attention to the '/' at the beginning.

Writing to IIS using Command Line

I am trying to install application using a script. This application creates a virtual directory under Default Web Site in IIS.
I have written this script. Is this right script or i am missing some thing.
cd C:\Users\Administrator\Desktop
msiexec /qb /i ZFPSetup.msi INSTALLLOCATION="C:\Program Files (x86)\Application" TARGETVDIR="ZFP" WIXUI_EXITDIALOGOPTIONALCHECKBOX=1 /l*v "C:\log.txt"
iisvdir /create Default Web Site ZFP C:\Program Files (x86)\Application\ZFP
call "C:\Program Files (x86)\Application\StartKaraf.bat" echo error
I am getting below error:
MSI (s) (28:D0) [04:25:58:897]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIF886.tmp, Entrypoint: WriteIIS7ConfigChanges
WriteIIS7ConfigChanges: Error 0x80070002: Site not found for create application
WriteIIS7ConfigChanges: Error 0x80070002: Failed to configure IIS application.
WriteIIS7ConfigChanges: Error 0x80070002: WriteIIS7ConfigChanges Failed.
CustomAction WriteIIS7ConfigChanges returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Error 0x80070002: Site not found for create application
Maybe this is caused by the lack of quotes, so instead of:
... iisvdir /create Default Web Site ...
Try:
... iisvdir /create "Default Web Site" ...
Using simple batch files is not the best way to go about configuring IIS. For system administration tasks such as this, Microsoft created PowerShell.
Check out how to configure IIS using PowerShell here: http://www.iis.net/learn/manage/powershell.
Here's an example of how to use PowerShell to create a virtual directory in IIS:
PS IIS:\> New-Item 'IIS:\Sites\Default Web Site\DemoVirtualDir1' -type VirtualDirectory -physicalPath c:\test\virtualDirectory1
The code above uses the PowerShell Snap-In for Creating Applications.
Good luck!

How to get rid of this error Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list

Using IIS7.5, the website works fine in Visual Studio but when I try to deploy on IIS get the following error.
Module IIS Web Core
Notification ExecuteRequestHandler
Handler PageHandlerFactory-Integrated
Error Code 0x8007000d
Requested URL http://localhost:80/EFT/default.aspx
Physical Path
C:\inetpub\wwwroot\EFT_Converter\default.aspx
Logon Method
Anonymous
Logon User
The version of .Net you are using has not been registered with IIS correctly.
If it is .Net version 4 on a 64-bit 2008 server use these two commands to fix it.
%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
Open command prompt on window and run:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\ aspnet_regiis.exe -i
This will resolve your issue.
Where your handlers are defined in the web.config, add a <clear /> before the first item in the list, if there is not one there already. Also make sure that the application pool running the web site is running the version of .Net that you are targeting in your code.
Try to set web config in this way:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
Ensure you have ASP.NET has been installed correctly. You should see default application pool named "ASP.NET 4" or something like this. If it's not looks like ASP.NET not installed correctly. Try aspnet_regiis -i in .NET 4 CMD.
Please go through this post.
From the post:
Click Start -> All Programs -> Accessories -> Run
In the Open textbox paste in the following line (see list of all .NET Framework version install, repair and unistall command lines here):
For silent repair on 32 bit computer with .Net Framework version 4.0.30319 use:
%windir%\Microsoft.NET\Framework\v4.0.30319\SetupCache\Client\setup.exe /repair /x86 /x64 /ia64 /parameterfolder Client /q /norestart
For silent repair on 64 bit computer with .Net Framework version 4.0.30319 use:
%windir%\Microsoft.NET\Framework64\v4.0.30319\SetupCache\Client\setup.exe /repair /x86 /x64 /ia64 /parameterfolder Client /q /norestart
2. Click OK to start the repair.
3. After, the repair ran for a few minutes, I restarted IIS 7.5, and things began to work correctly!
I had this problem and found that removing the following folder helped, even with the non-Express edition.Express:
C:\Users\<user>\Documents\IISExpress

Unable to export RSA Key container file

I need to encrypt my web.config file on my dev machine (Windows XP SP-3) and export the RSA Key to my QA machine (Windows Server 2003). I used the following command to encrypt my file.
aspnet_regiis -pe "appSettings" -app "/VirtualDirectoryName" -prov "RsaProtectedConfigurationProvider"
and then i added the following section in my web.config file
<configProtectedData>
Then i created the RSA container with the name "SampleKeys"
Web.Config was encrypted nicely and i was able to use this file on my dev machine. I however had to turn on "Impersonation" and used my windows userName and password.
I need to export my RSA Key to QA server, so that i can use my the encrypted config file.
So i'm trying to export the RSA key and its failing. I don't understand the reason, as i'm following all the steps that are mentioned in the following link;
link text
When i try to export the RSA container, i get the error saying that the "RSA container was not found." But when i try to create the RSA container again with the same name, i get the error stating "The RSA container already exists".
even the following command executed successfully.
aspnet_regiis -pa "NetFrameworkConfigurationKey" "NT AUTHORITY\NETWORK SERVICE"
I however could not execute the following command;
aspnet_regiis -pa "SampleKeys" "NT AUTHORITY\NETWORK SERVICE"
I got the same error saying that "RSA container was not found."
I also gave read access to ASPNET user on "C:\Document and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKey" folder.
but nothing worked.
Am i missing something?
Found the answer! You always need to reference the "SampleKeys"-exp once you create a key for exporting.
aspnet_regiis -pa "SampleKeys"-exp "NT AUTHORITY\NETWORK SERVICE"
Be sure to open the command window as an administrator. And try again.
Also, in this thread:
http://forums.asp.net/t/960412.aspx/1?RSA+Key+container+was+not+found+ERROR
a default container was created using this command:
aspnet_regiis -pc "NetFrameworkConfigurationKey" -exp

Resources