Configuring web.config for two different sites of same application - c#

I have two urls of my application,suppose url/site1 and url/site2.
On url/site1 we have implemented Ad authentication and url/site2 has application login for external users. Now there some attributes in web.config due which i'm having separate deployment folder each mapped to /site1 and /site2 under default website. I want to maintain only one set of deplyment folder . Is there a way i can configure different scenarios for each of this websites under same web.config.Mainly these 4 lines given below will have different values for each site, how can i accommodate it in same web.config so that i can keep only one deployment folder mapped to each of these sites in IIS manager.
<add key="owin:AutomaticAppStartup" value="true"/>
<add key="VirtualDirectory" value="/XYZ"/>
<add key="SiteName" value="XYZ"/>
<defaultDocument>
<files>
<clear />
<add value="UserLogin.aspx" />
</files>
</defaultDocument>

Related

HTTP Error 403.14 ASP configuration

I get this error while trying to initiate a project in ASP. I have already added
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
To the Web.config but I still get this error. Also, I have tried initiating the IIS Express by opening appcmd.exe but this did not fix it either. None of the solutions I have found worked for me so far.
Any ideas?.
Step 1. Open IIS
Step 2. Go to the WebSite you are facing issue with.
Step 3. Click on Default Document Button, you will find it on the right side tab in IIS.
Step 4. You can see a list of default documents, but your default page (aspx file) is not mentioned here and that is causing the issue.
Add your file here. (For example: Index.aspx)
You can also add the following entry into the web.config:
<system.webServer>
<defaultDocument>
<files>
<add value="Index.aspx" />
</files>
</defaultDocument>
<directoryBrowse enabled="false" />
</system.webServer>
Hope it helps.

App Settings from Web.config in WCF Service returning null

I am having an issue retrieving app settings from my web.config file in a WCF service I am creating. When calling my settings, I am retrieving a null value. Digging into the object also shows that there are no keys in AppSettings list.
This issue has a few posts around SO/Google, and I have incorporated all the suggestions, but to no avail. Here is my current position and what I have tried:
web.config:
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<!-- CRM Creds -->
<add key="CrmUrl" value="[removed]"/>
<add key="CrmUser" value="[removed]"/>
<add key="CrmPass" value="[removed]"/>
</appSettings>...
Methods of calling the settings:
System.Web.Configuration.WebConfigurationManager.AppSettings["CrmUrl"]
System.Configuration.ConfigurationManager.AppSettings["CrmUrl"]
The file I am calling from is within a folder, whereas web.config is in the root. I understand WebConfigurationManager could find this regardless, but I am having no luck.
Code:
%projectfolder%/Client/Client.cs
Config: %projectfolder%/web.config
I have run out of things to try and have used up all my Google-fu. Any suggestions are appreciated.

Make static resource available in Azure Web Role

I need to access a web api in an Azure Web Role from a legacy Flash Application, and in order to do this Flash needs to be able to access a file called crossdomain.xml. I have added this file to the root of the application, but if I go to https://myapp.com/crossdomain.xml in the browser the file is downloaded. How can I get the xml to be shown in the browser?
Static xml files can be served by adding the following to web.config:
<handlers>
<add name="XMLHandler" type="System.Web.StaticFileHandler" path="*.xml" verb="GET" />
</handlers>
<staticContent>
<mimeMap fileExtension=".xml" mimeType="application/xml" />
</staticContent>

how to redirect from folder in a web server

i have two different applications, one is a website project running on the the server root, the second is a web application project in a folder, both projects have their configuration files, and i am putting the link in the configuration file of the website project
i am trying to redirect users from the website project to the web application project, whenever i use this:
<add key="CoronaPortalAddress" value="http://localhost/coronaportal/Security/ApplicantSignIn1.aspx?applicationType=" />
<add key="CoronaPortalSignInPage" value="http://localhost/coronaportal/Security/SignIn.aspx" />
<add key="CoronaPortalTimeTablePage" value="http://localhost/coronaportal/Conona Schools_ Trust Council_ApplicantTestScores/TimeTable1.aspx" />
<add key="CoronaPortalResultsPage" value="http://localhost/coronaportal/ParentReportLogin.aspx" />
users will be redirected, though on the url it will showing localhost, so i change it to:
<add key="CoronaPortalAddress" value="http://www.shodsystems.com/coronaportal/Security/ApplicantSignIn1.aspx?applicationType=" />
<add key="CoronaPortalSignInPage" value="http://www.shodsystems.com/coronaportal/Security/SignIn.aspx" />
<add key="CoronaPortalTimeTablePage" value="http://www.shodsystems.com/coronaportal/Conona Schools_ Trust Council_ApplicantTestScores/TimeTable1.aspx" />
<add key="CoronaPortalResultsPage" value="http://www.shodsystems.comcoronaportal/ParentReportLogin.aspx" />
now it throwing error:
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS
i tried to google this, but couldnt fix it, any assistance would be appreciated.

How to Configure UrlRewritingNet on asp.net web application client end

Please am fairly new to programming in asp.net and now am following the steps in a textbook to design an e-commerce web application.
I am using UrlRewritingNet dll from http://www.urlrewriting.net/ to create search engine friendly urls on the application. I unzipped the urlrewritingnet zip and copied its dll file to my application's bin folder. I also copied its urlrewritingnet.xsd file to my project folder. The textbook am working from uses the dll from urlrewriter.net with different configurations which I tried in my project but it didn't work. The textbook also uses visual web developer 2005. Am programming in visual studio 2012 (C#). For now am trying to rewrite the url of my catalogs page so as to test if the configuration in my web.config file is correct. I'm doing the configuration in my web.config, not in IIS. I do not want any IIS configurations because am imagining a scenario where I don't have access to the server.
I keep getting an internal server error that displays like this:
HTTP Error 500.22 - Internal Server Error
An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.
this is the url which I want to rewrite: http://localhost:1036/Catalog.aspx?DepartmentID=1
This is my config file:
<configuration>
<configSections>
<section name="urlrewritingnet"
restartOnExternalChanges="true"
requirePermission ="false"
type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter" />
</configSections>
<urlrewritingnet
rewriteOnlyVirtualUrls="true"
contextItemsPrefix="QueryString"
defaultProvider = "RegEx"
defaultPage = "Default.aspx"
xmlns="http://www.urlrewriting.net/schemas/config/2006/07" >
<rewrites>
<add name="Rule1"
provider="RegEx"
virtualUrl="^.*-d([0-9]+)/?$"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/Catalog.aspx?DepartmentID=$1"
ignoreCase="true" />
</rewrites>
</urlrewritingnet>
<appSettings>
<add key="MailServer" value="smtp.gmail.com"/>
<add key="MailUsername" value="engr.ejikeeze#gmail.com"/>
<add key="MailPassword" value="keeplooking"/>
<add key="MailFrom" value="engr.ejikeeze#gmail.com"/>
<add key="EnableErrorLogEmail" value="false"/>
<add key="ErrorLogEmail" value="engr.ejikeeze#gmail.com"/>
<add key="ProductsPerPage" value="6"/>
<add key="ProductDescriptionLength" value="60"/>
<add key="SiteName" value="BalloonShop"/>
</appSettings>
<connectionStrings>
<add name="BalloonShopConnection" connectionString="server = (local)\SQLEXPRESS; Database = BalloonShop; User = balloonshop; password=ecommerce" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<httpModules>
<add name="UrlRewriteModule"
type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" />
</httpModules>
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US"/>
<customErrors mode="RemoteOnly" defaultRedirect="Oops.aspx" />
<pages theme="BalloonShopDefault">
<controls>
<add src="~/UserControls/DepartmentsList.ascx" tagName="DepartmentsList" tagPrefix="BSUC"/>
</controls>
</pages>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
</configuration>
Pls I need you lovely guys to help me out. Am really stuck. I've searched all round the internet for over 4 days in search of solution but to no avail. Thanks in anticipation.
You can checkout the following link:url-rewriting-in-Asp-Net

Categories