How to implement machine name in elmah subject line? - asp.net

I want to carry the machine name in ELMAH subject line. As in developing environment want to keep the track that from which machine error is coming. So I want implement subject line with proper machine name. What I should do?
<elmah>
<errorMail name="exceptionMail"
from="devsupport#abc.co.in"
to="devsupport#abc.co.in"
async="true"
subject="Error log from [should come machine name here]"
smtpPort="0"
useSsl="true"/>
<security allowRemoteAccess="yes" />
</elmah>

As far as I can see, there's no way to do this in config alone - you would have to write some code to handle this requirement.
On the other hand - it seems pretty simple and straightforward to write that code.
See this blog post Customizing ELMAH’s Error Emails by Scott Mitchell on how to do it.

Related

The remote name could not be resolved: 'maps.googleapis.com'

I have an asp.net web application that uses Google Maps. Everything has been running fine for quite some time. All of a sudden yesterday, no calls to Google API would process. I assume we reached a query limit but upon checking, all quota totals were 0. I then realized we were not including our API Key in the requests. I added the appropriate API key and the maps came back online. However, I still cannot GeoCode a address using the following:
maps.googleapis.com/maps/api/geocode/xml?address=(PROPERTY-ADDRESS)&key=(OUR-KEY)
returns:
The remote name could not be resolved: 'maps.googleapis.com'
We get the same error when trying to use:
maps.googleapis.com/maps/api/distancematrix/xml?origins=(LOCATION1)&destinations=(LOCATION2)&units=imperial&key=(OUR-KEY)
However all calls to:
maps.googleapis.com/maps/api/js?key=(OUR-KEY)
work fine.
This code has worked fine for a long time, with no modifications.
We are on a dedicated server, using the same IP, However the site does run through Incapsula (Not sure if that makes a difference)
I already added:
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true">
</defaultProxy>
</system.net>
but this did not help.
The error: The remote name could not be resolved makes it seem like a DNS issue, but the server is online and can resolve maps.googleapis.com/maps/api/js without any problem.

debug .NET aplication only from one IP adress

Here is my problem.
I have one server on the other side of the world with IP 1.2.3.4
If I put in web.config this
<compilation defaultLanguage="c#" debug="true" />
everyone sees a debug, I want to set something like
<compilation defaultLanguage="c#" debug="true" IP="4.3.2.1" />
So only IP 4.3.2.1 can see debug for that site all other IPs should see like
<compilation defaultLanguage="c#" debug="false" />
is set.
The setting says how the whole page is compiled. Then in this form it is served to all clients. If you want this, you can have two sites - one normal and one debug - and if there is one particular IP requesting your site you can redirect it to the debug version.
What do you intend to do? You are fiddling with the compilation element, that is, you try to modify the compilation of your code. Code is not compiled per-request or per-user.
If you want to reveal/hide stack traces you may want to use this instead:
<customErrors mode="RemoteOnly" />
However, this does not allow to filter by IP except the loop-back. IP addresses are generally not a very secure way to identify a person or to prevent an authorized person from retrieving the stacktrace.
If you have remote access to the web server, you can log in and use http://localhost to access your web site. If you have RemoteOnly active, you will find the stacktrace of your error then.
If you still want to go for an IP-based approach, you might find something at Rich Custom Error Handling with ASP.NET. The section "Rich Custom Error Pages" mentions "Logic to display detailed information only to certain IP addresses may be included here."
(I found the article by googling for "asp.net reveal stacktrace to certain ip only")

About log4net config

I have debugged the code leaving to us from a vendor for several months. Till today I just find that the log4net configuration still contains vendor's information.
My simple question:
Does the vendor can track and record my work during the period? Is it secure for my pasted work?
What is the smtpHost IP?
<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
<to value="somebody#some_vendor.com"/>
<from value="person#some_vendor.com"/>
<subject value="Company Portal"/>
<smtpHost value="xy.a.b.cd"/>
<authentication value="Basic"/>
<username value="somebody#some_vendor.com"/>
Thank you.
Ok, it isn't secure, because if your application has internet access and smtphost is available and works, then everything, that logger is supposed to log will be mailed to developer.
Look through the code, what type of messages are loged?
smtphost is dns name for machine that provides stmp service, for sending emails.
The smtpHost is the ip or domain of the smtp server to use when the SmtpAppender is called.
So any level configured to be logged using the smtpappender generates an email using that smtpserver as host.
The server your code is running on has to be able to connect to xy.a.b.cd in order to be able to send messages.

Web Deploy dump dirPath not working with delegation and a non-Admin user

I'm trying to run the following Web Deploy command:
msdeploy.exe -verb:dump -source:dirPath="C:\Deploy",wmsvc=localhost,username=<user>,password=<pass>
I have tried to run this with two users, John and Mary. John is a member of the Administrator group on the box, Mary isn't; the command works for John, but fails with a 401 for Mary.
I have the following set up:
Mary has full access to C:\Deploy via the ACLs (as does the Administrators group)
Both John and Mary have been granted access to the C:\Deploy dirPath in IIS using the delegation functionality (see below)
My administration.config entry:
<rule enabled="true" providers="dirPath" actions="*" path=".*" pathType="RegularExpression">
<runAs identityType="SpecificUser" userName="AnAdministrator" password="..." />
<permissions>
<user name="PC\John" isRole="false" accessType="Allow" />
<user name="PC\Mary" isRole="false" accessType="Allow" />
</permissions>
</rule>
When I add Mary to the Administrators group, the command works. But the whole point of delegation is to be able to run deployment commands as non-administrators. I'm able to run other commands (e.g. -verb:dump -source:appHostConfig="Default Web Site") fine for Mary - it's just dirPath that's not working.
WMSvc.log doesn't seem to contain any errors for the failing command - I can see the successful ones fine though. I do see the 401 for the HEAD request in the failed requests trace, but no indication as to why it's occurring...
Any pointers appreciated.
zcrar70, you are right: delegation only kicks in once a user has access to a site's scope. In your example, if you had given PC\Mary access to the site (via IIS Manager Permissions), then this would just work.
Can you explain your scenario a bit further? Are you trying to give a non-admin user permission to run specific providers on ALL sites?
Your RunAs identity "AnAdministrator" needs to have permissions to access c:\Deploy, since both Mary and John will be impersonated (if the original identity fails, which doesn't for John) as this user. ACL C:\Deploy for AnAdministrator user and try again.
You can also use ServerValidator tool to check whether your environment is ready for delegated deployment.

SMTPClient Half Working \ Half Not

I am using Microsoft's membership framework on a website. I am able to send password retrieval e-mails, but am unable to send e-mails myself using SMTPClient.
When you configure the SMTP settings in the Web Site Administration Tool, what are the settings that this application give it's SMTPclient?
If I know this, I can duplicate it and hopefully send e-mails.
A few items I've ruled out.
- I'm using port 25, (which is the only one allowed under medium trust).
- This code works on my local system.
I was attempting to pass the values for SMTPClient in with the constructor. What I failed to realize is that SMTPClient apparently automatically pulls the values from web.config and uses those.
By trying to pass my own values (even though they where identical); I inadvertently violated trust levels causing a security exception.
Don't pass in smtp info in the constructor, use web.config to set it up, and there should be no problem in medium trust.
It could be lots of things, from credential problems, DNS issues, or...who knows. Is it unable to send as in you get an error or as in they appear to go but never arrive?
Are you sure the WSA tool is going through SMTPClient, or are you just assuming it (I don't know myself)?
-- MarkusQ
I am getting a Security Exception on
my mail
That sounds like a credentials problem then, or a trust issue. Are you sure you're running at medium (or higher) trust? What's the rest of the error?
-- MarkusQ
Try checking your web.config file: is the WSA tool updating these settings?
This element is under the configuration element
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="you#email.com">
<network
host="your.gateway.com"
userName="your#email.com"
password="your_password"
port="25" />
</smtp>
</mailSettings>
</system.net>

Resources