Separate NewRelic Application for each ASP MVC Area - asp.net-mvc

I'm trying to split ASP MVC areas into separate applications within New Relic.
Within each area I have created a new web.config file that simply contains the below XML. This doesn't seem to be creating a new application like I would expect it to.
It works when it is in the root web.config. I don't have this key in the root config of this MVC application, however.
Any help would be appreciated - otherwise it might just be something that cannot be done?
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="NewRelic.AppName" value="My Area Name" />
</appSettings>
</configuration>

The New Relic .NET agent can only gather settings from a web.config file in the app root. Unfortunately, there isn't a way to set NewRelic.AppName on the fly using the API or specify a path for per-app config files. You might write into support#newrelic.com and submit a feature request.

Related

Azure Web App redirects to localhost URL when testing on web; redirects to web URL when testing locally

I am attempting to have seamless movement between locally testing and cloud testing of my Azure Web App. The following is a snippet from my Web.Config file.
<appSettings>
<add key="ida:ClientId" value="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" />
... more items ...
</appSettings>
The value of ClientId corresponds to the value of an "App Registrations" object within my Azure Active Directory instance. When I click on that object and navigate to Settings --> Reply URLs, the entry is https://localhost:xxxxx/.
My problem is: When I publish the Azure Web App to the cloud, I am redirected to the above localhost URL. However, if I add another Reply URL entry of https://mywebappname.mydomain.com, then when I attempt to test locally, I am redirected to the web URL instead of the localhost URL.
I would like a method of seamless local and cloud testing: When testing locally and on the cloud, I would like to be redirected to the correct URL. What configurations am I missing in order to accomplish this?
---- UPDATE ----
Also when I right click on the Web Application project in Visual Studio 2017 and then click Properties, I am taken to this screen. Here are some additional properties I have set, which redirect to https://localhost:xxxxx/. Do I need to change this? And if so, how can I have both redirect URLs within the project's properties?
I ended up solving this problem by using the Web.config Transformation Syntax (see Stephen Muecke's link in the comments on the original post).
In the same directory as the Web.config, I added a Web.Release.config. Now, if in Visual Studio I select "Release" build, then the Web.Release.config transform config file will be used to replace the Web.config file's "ida:RedirectUri" key with the value in the transform config file.
Here is the Web.Release.config
<?xml version="1.0"?>
<!-- For more information on using Web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=301874 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="ida:RedirectUri" value="https://<mywebappname>.<mywebappdomain>.com/" xdt:Transform="Replace" />
</appSettings>
</configuration>
And here a snippet from the very large Web.config
<?xml version="1.0"?>
<!-- For more information on using Web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=301874 -->
...
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
...
<appSettings>
<add key="ida:RedirectUri" value="https://localhost:xxxxx/" xdt:Transform="Replace" />
...
</appSettings>
...
</configuration>
That way, redirecting to localhost is the default.

Publishing an MVC4 App on IIS 7.5 but Having Permission Issues

I published an intranet on IIS 7.5. If I try to go to the website, I get "403 - Forbidden: Access is denied - You do not have permission to view this directory or page using the credentials that you supplied".
If I right click on the application folder on IIS Manager and go to Manage Application and then Browse, I get "HTTP Error 403.14 - Forbidden - The Web server is configured to not list the contents of this directory". It then proceeds to tell me that A default document is not configured etc. etc. I do have a default document listed in the web.config file as follows:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<modules runAllManagedModulesForAllRequests="true" />
<defaultDocument>
<files>
<add value="Index.cshtml" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
What am I doing wrong? Many thanks.
check the folders permissions: right click on the folder, click on properties go to Security and add the appropriate user (like IUSR_...). hope it helps.
It turned out I was publishing the app completely the wrong way. I was going by how previous ASP.Net apps created as Websites and not Solutions were published. This MVC app needed to be placed in inetpub/wwwroot folder in the server. If I published through Visual Studio I think this would have happened anyway. I didn't have VS in the server. So I placed the files manually there (just copied from my local inetpub/wwwroot since I successfully published there earlier). The last thing I needed to do was go to IIS Manager and converting the project folder into an Application. Now cooking on gas.

MVC Publish to host is adding extra sub folders

I'm publishing an MVC 3 site to a go daddy account. I'm using the FTP Publish utility in VS 2010. The site publishes "okay". But here is the issue:
On my local machine, when I run it the web address is:
localhost/Student/Create
On my go daddy account, I have created a subdirectory called mvctest.
I have created a subdomain called mvctest.mysite.com that points to the virtual directory at mvctest. This works fine.
But after I publish my site to www.mysite.com/mvctest, I am getting an additional /mvctest/ directory in all of my links. What I want is:
mvctest.mysite.com/Student/Create
what I get is:
mvctest.mysite.com/mvctest/Student/Create
What's interesting is that if I manually type in what I want, the page loads fine. If I've hard-coded a link to the root, it's fine, but all of my Url.Content and Html. Links add the additional mvctest directory..
I've searched all over and haven't found an answer to this dilemma. I tried in the web.config, but I don't think that does it. I feel like something in the FTP Publish utility in VS2010 is altering the routing structure in my global.asax file, but I'm not sure.
Any suggestions appreciated.
Is your virtual directory an application? If it's not set as an application, IIS will treat the root of your site as the application and add the subdirectory. See this post.
The following solved the same issue for me and is quoted from a blog post I found (source):
So now for the solution, and I probably should have mentioned this at the beginning but hopefully you’re using IIS7 with the URL rewriting module installed (it is installed by default when you use IIS7 on GoDaddy).
Simply add the following into your web.config’s system.webServer element:
<rewrite>
<rules>
<rule name="Remove Virtual Directory">
<match url=".*" />
<action type="Rewrite" url="{R:0}" />
</rule>
</rules>
</rewrite>
All this does is “rewrite” the URL with itself. This causes URL Rewrite to add the original URL (the one with no folder name) to a ServerVariable which is used by ASP.NET MVC to generate other URLs.

Does Umbraco allow non-umbraco subdomains

Hi I am installing Umbraco to the root directory of my website. And also I want to install my wordpress blog to a subfolder in the root directory.
However any request to the subfolder is being intercepted by Umbraco and it is showing that document URL cannot be found. Is there a way to make Umbraco ignore certain subdomains?
You can tell Umbraco to ignore certain paths or folders in the web.config.
You need to update the following entry in the appSetting section of the web.config:
umbracoReservedPaths
Add the subfolder you wish Umbraco to ignore in there.
i.e.
<add key="umbracoReservedPaths" value="/umbraco,/install/,/wordpress/" />
There are more details on the Umbraco web.config settings in on our.umbraco.org
it's useful for binding too:
<add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/http-bind/" />
~/http-bind/
Thanks Tim Saunders
You can also use umbracoReservedUrls to tell umbraco to ignore specific pages:
<add key="umbracoReservedUrls" value="/mypages/regular-page.aspx" />
This can be set up with in IIS by setting up the blog as a separate application with in the umbraco site.
However if you are trying to make a sub-domain there is no reason why this should be in the same site, I would say it is best to create a separate site with in IIS or purchase another hosting account to host the blog separately

"Resource not found" error while accessing elmah.axd in ASP.NET MVC project

My ASP.NET MVC application is within a folder called Stuff within IIS 6.0 webroot folder. So I access my pages as http://localhost/Stuff/Posts. I had EMLAH working while I was using the in-built webserver of Visual Studio. Now when I access http://localhost/Stuff/elmah.axd, I get resource not found error. Can anyone point my mistake here! Here is config file entry,
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/> //Handler
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/> //Module
Working with IIS7 I found I needed both sections of the web.config populated (system.web AND system.webServer) - see Elmah not working with asp.net site.
Perhaps this is related.
Have you added an ignore *.axd routes in global.asax?
For Elmah, we need to differentiate between two things:
First the http modules doing all the work of error logging, emailing...etc.
Second, the http handlers, displaying the error log page and other pages (rss...etc.)
I was having the same problem of 404 resource not found because I have a weird setup!
on my development machine, (windows 7, iis 7 ) elmah was working like a charm because the application pool was working in the integrated pipeline mode. In the production machine, however, the application was using the managed pipeline and I tried all my best to make elmah work but it was all useless...
I then got the idea of displaying the UI (error log page, rss, error detail,...) using regular aspx pages.
I downloaded the source code, made some changes (sorry Atif, I was forced to do this because I needed the quickest solution) and then in my application , I created a folder under which I created regular aspx pages which inherits from Elmah defined pages.
The page only contains one line (ex: for the detail page: <%# Page Language="C#" Inherits ="Elmah.ErrorDetailPage"%>)
Now, I was able to run Elmah regardless of IIS 6/7 and it is working like a charm.. and It saved me from a big headache of correctly configuring http handlers and troubleshooting its work! additionally, configuring security is much simpler!
I don't know if the community is interested in this solution (If so, I am ready to post my full changes).
Hope that this gives you an idea on how to solve the problem in an alternative way (and if you need the modified dll with complete instructions on how to use it, just tell me!)
In the application pool settings in IIS set Managed Pipelin Mode to Classic if you don't want to change code or the web.config file. Your axd.s will then work as before.
Can you post the rest of your web.config?
Or, if you're comfortable enough, can you just ensure that the httpHandlers and httpModules (NOT handlers and modules) sections are filled in properly in the web.config?

Resources