Find Website Name from a web application - asp.net

I have two web site sites on IIS 7 (Default, Custom). Both Sites host the same web application.
Some of the web application behavior changes depending under what web site it is running. Is there a way for the web application to find out what is the name of the WebSite under which it is handling the current request.
Thank you
Imran

System.Web.Hosting.HostingEnvironment.SiteName
will get you the site name as it appears in IIS
Request.Url.Authority
will get yo the requesting url

Related

IIS URL Rerouting MVC 404 Error - Hangfire

I'm trying to add an MVC site under a domain where there is an existing site. The new site is just a simple mvc site to show a hangfire dashboard. I'm using IIS 8.5.
The current site is an old ASP.NET Web Forms site and will not allow the routing to the new MVC application and I get a 404.
The old site needs to be accessible at https://example.com and I need to be able to access the Hangfire site at https://example.com/Reporting/hangfire.
I have the MVC application configured and it works when the physical path of the Web Forms site is not pointing to the root folder (example.com).
I am new to the routing configuration in IIS so I am not sure if there is a URL Rewrite rule that would be useful for this or if need to do something else.
Edit
This is the root site, its a web forms site deployed by someone else. I added the MVC site as an web application and it uses a different app pool. I get a 404 in this case because the web forms app is handling the routing and its never getting to the MVC app.
I was able to get this working by deploying the site under a sub-domain; I had to convince our admin to allow this. The MVC site worked on its own but never when nested under the Web Forms site.

Is it possible to inject html footer from IIS for all site?

I have a iis 8 server running in windows server 2012. Currently 3 different websites are running on it and the other two will be integrated shortly. All 5 websites are being managed from their respective owner. I want to append 'hosted at xxxx' at the bottom of all pages that is being served by this iis. I can do it application wise is global.asax, but is it possible to do that at iis level, so that I donot edit the hosted application? All websites are in .net 4 and form based.
Yes, you can write an IIS Module that will inject HTML into the HTTP Response Stream. You can add this Module to each application individually by dropping the DLL into the app's BIN folder and registering it in the Web.Config. Alternatively you could create a Strong-Named Assembly and register it with IIS for all sites.

IIS 7.5 web site containing web services where one of the web services returns a 401 error

BACKGROUND : I have an IIS 7.5 site containing thirteen different web applications where each application is simply hosting different web services. Nothing fancy. Here is a graphical view of the site.
Each of the web applications are running under their own application pool, all running .NET 4.0 Integrated Pipeline under the ApplicationPoolIdentity.
At the site level I have set the Authentication to be the following
When I try to access the web services within one web application I get 401 errors. All other web services in the other web applications can be accessed without errors.
Here is a snippet of the IIS log when the error occurs. The errors are the same when using a web service proxy class or when accessing the web service url via the browser.
Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+4.0.30319.269) 401 2 5 17721
Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+4.0.30319.269) 401 1 2148074254 15
If I access the Url directly from the browser I am prompted for my credentials. If I enter my domain credentials I still get the 401.1 error. :(
This error is repeatable on all devices in our domain, so it is not isolated to my machine.
I have verified the folder structure containing the web services in question has the same permission as the other folder structures of the twelve web services that work.
The Site is running in Kernel-mode authentication which is the default.
QUESTION: I'm a developer with limited knowledge of IIS. Anything else I could look at?
Thanks
The answer to my problem was rebooting my server. Still never got a definitive why the issue was occurring.

Sharepoint site as a subsite under a asp.net site

I have asp.net hosted at my domain which i access using a url like 'http://www.xyz.com. I have other web applications which are under the root web application in virtual directories which can be accessed using a url like 'http://www.xyz.com/subsite1 etc.
Now i want to have a sharepoint site as a subsite under my root website which i can access using a url like 'http://www.xyz.com/sharepointsite1.
I have installed sharepoint 2010 server.This installed a new website Sharepoint-80 and The central administration site. I have changed the Sharepoint-80 website setting to point to wwwwroot where my asp.net wesite and its subsite files are located. Now if i make a new site collection in my sharepoint site and it gets successfuly created. But when i browse it i get following error.
HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.
My webserver is also a domain controller. How do i resolve this issue? And how do i achieve the main aim of having a sharepoint site as a subsite under my main website?
Thanx
I don't think that is possible, unless you are using different host headers or you can write an HttpModule which would be complex in my opinion. Although reverse is possible, You can have a sharepoint site at / and then an ASP.NET site at /subsite
The reason is an IIS SharePoint website is different from IIS ASP.NET website. IIS SharePoint Website registers an extra SPRequest module which fetches the data from SharePoint content database. When you request / , it will always try to pull this data from the SharePoint Content database.
In your case, where you have changed the SharePoint-80 website to point to wwwroot, you have essentially removed SPRequest module from the pipeline. That's the reason you get the error, because its not able to pull the content from the database.
You should do the other way around. Change main site to Sharepoint site, and let your other asp.net application/site to be subsite of sharepoint.
You cannot do that. Simply because you're trying to encapsulate a cloud-based system into an internal IIS folder structure.
You can not add Sharepoint online page in an iframe because of the same origin policy that most of the sites on internet adopted this days. This is mainly for security reasons to avoid from web attacks like Clickjacking and XSS.
You can not add Sharepoint online page in an iframe because of the same origin policy that most of the sites on internet adopted this days. This is mainly for security reasons to avoid from web attacks like Clickjacking and XSS.
If you want to display the content of the sharepoint online into different domain, than try to use provider hosted app in windows azure or develop a Napa sharepoint hosted app which can make cross domain requests in REST or ajax

how to make an web application in demo in our comapny web site

i have developed an web application[ERP FOR A SCHOOL].i have given the build for it is working fine, but now i need to provide this web Aplication in my company web site where user's[clients] can see the Web applicatin . now what is this web applicationis all a out. our application is developed using using Sql Server 2005, .net 3.5(vs2008).
now i need to provide an link button type in our company web site. once the user clicks that link button. a new window should open which will take us to the web Apllication demo[ERP School Application]
how to achive this. any idea how to get it done. what are the things that i should take care here
any help would be great
thank you
Create a new website in IIS and linking to it.
OR
Merge the website and application by:
Completely merging then into one system.
Creating a virtual directory for the application.
Making the Application the WebSite/Root application and creating a virtual directory for the website
Whole this setup fully dependent on which platform your web server is?
sceneario1: company web server is on linux
1. You need to get permissions from you web administrators for editing pages and server login and passwords. You can use telenet to login on your company web server
2. Create a new IIS (internet information server) on seperate windows m/c. setup this server with sql and web address. look in http://support.microsoft.com/kb/323972
3. Add this new web address in your company web page as link.
sceneario1: company web server is on windows
1. You need to get permissions from you web administrators for editing pages and server login and passwords.
2. Check if sql is available on server
3. create new folder and put you whole web project in it.
4. Edit existing page from web.
This will not mess up any thing on your company server.
Er, why can't you just create a virtual directory or a new site in IIS and put a link (with a target="_blank") to it on the parent site?

Resources