Problem with SMTP in IIS7 - asp.net

I have an ASP.NET app that works fine on my windows XP dev machine but doesn't work when deployed to a Windows 2008 with IIS7. The app uses SmtpDeliveryMethod.PickupDirectoryFromIis and gives an error when I try to send an email from the app on IIS7 (an SmtpException with the message "cannot get iis pickup directory"). I use the same settings on both the dev machine and the server.
Any help would be really appreciated ...

It turned out to be a permissions problem but not with the pickup directory, actually with the metabase (SMTP settings are still saved in the metabase in IIS7)
I came across this forum thread, Cannot get IIS pickup directory. NEED HELP, on IIS.net forums website then followed what was mentioned in the posts, downloaded and installed the metabase explorer tool (you have to download IIS6 resource kit to get it) then gave read permissions to my custom user (as indicated in one of the posts) on the LS, SMTPSvc and SMTPSvc/1 keys and it worked. For some unknown reason if you only give permissions to the smptSvc key it doesn't work.

I think the problem could be with trust levels.
Because in medium trust you can only write to your application's directory (or any directory below that). And if the PickUp folder which you specified is not in your application's directory AND the application is running under medium trust (not full trust), then you can't write to the PickUp folder.

You may send directly to the SMTP server without using a pickup directory.

You need to specify the Pickup directory first. Here's a guide on how to do it.
Also it's not a good idea to compare your IIS 5.1 on an XP box against the one on your Windows Server 2008 (IIS 7), since besides the obvious version difference a lot of features have changed a lot. Specially the smtp server, for instance there's no such feature in Vista.

Related

Problems publishing site to localhost on windows 2008 rs server

I must preface this post by saying that I am not an experienced developer, I am in the process of learning through trial and error and a lot of google searches so detailed (step-by-step) feedback would be greatly appreciated. I created a website, which does not use a database, using visual studio 2015 and I am attempting to host it locally on a Windows 2008 R2 server.
I installed IIS and loaded the asp.net v4.0 framework. The site works fine, produces no errors when I test it and works after being published only if the visual studio is still running.
However, when I close the Visual studio and open my browser window to http://localhost:50044 (which is the URL listed in properties menu in VS), I also tried using port :80 and nothing. When trying to add Web Site via the IIS management utility I receive the following authentication error: ”Cannot verify access path (C:\Inetpub\wwwroot).”
I checked the permissions and windows authentication is enabled with read access, and all other permissions seem to be correct. I am at a loss, I'm sure it is probably something simple that I am missing due to my lack of knowledge and experience. Any help would be appreciated.
It's sounds like you are running on IIS express which in your case stops running when you close visual studio. Normal process is create a new website in IIS and point to the folder where your web.config is. You can then hack your host file (C:\Windows\System32\drivers\etc) so DNS works. Add an entry like "127.0.0.1 mytestwebsite.com". I hope that helps
So I figured out part of what was happening. I didn't realize that visual studio has built in IIS and was using that by default.
I ran VS as an admin, created a new project, then attempted to create a virtual directory thru VS under the project/properties/web tab. I selected local IIS and entered http://localhost/boc and it returns an error: unable to create vd. Web server http://localhost... Could not be found.
I then went in to the IIS manager and set up a virtual directory with no issues. However, when I attempt to reference it thru VS I again receive an error message.
Any ideas?

Page is not accessible when I close Webmatrix

I have a server (devserv) with Webmatrix installed. Under settings, I modified the URL so it's now http://devserv:8888.
That allows me to access the 2 sites that I'm working on.
However, that works only I have Webmatrix open. When I close it, the sites are not accessible.
They are not accessible locally either, btw, but I'm giving you the full picture just in case.
The error that I get is that the web.config cannot be read to do insufficient rights.
However, all domain users have the right to read and execute on the folder that contains the sites and I checked the rights go down the tree.
So the question is what am I doing wrong, and why when Webmatrix is open, then there is no problem.
This is a Windows 2008 R2 server Standard and IIS is 7.5.7600.16385
WebMatrix only starts up the IIS Express server for a given site while you are editing it (with WebMatrix open). When you close WebMatrix, we shut down the IIS Express process. IIS Express is really only meant to be used during development time - if you want the site to continue to be available, I'd suggest installing full IIS on it, and using WebMatrix publishing to push your files to the server with Web Deploy.
Hopefully this helps!

Debugging with VS2008 will not work after changing Hostname

I am currently using Visual Studio 2008 on XP Pro SP3.
Developing against http://localhost/ everything including debugging works fine.
I need a second website on my machine. IIS 5.1 only allows one website at a time so I used the JetStat XP Pro IIS Admin tool to create a second website. This runs by stopping the Default website and starting the other.
I have added the new website name into the Hosts file and mapped to 127.0.0.1.
Websites can be accessed via this address http://NewHostname/VirtualDirectoryName
Projects can be started without debugging (Web Applications & Websites).
However, when I try to debug I get an error: "Unable to start debugging on the web server. An authentication error occurred while communicating with the web server."
Integrated Authentication is enabled in IIS.
I have seen a lot of documentation with many fixes for "unable to start debugging on the web server" errors but they all seem like huge overkill for my problem, after all, debugging works fine provided I'm not doing it on this different hostname. They talk about doing things that I would do if debugging did not work at all even with http://localhost/.
Is there a place where I can just add this new hostname so that VS debugging is allowed? Do I need to change permissions somewhere? I feel like there should be a really simple solution that I'm just overlooking.
Here's a description of the problem: http://blogs.msdn.com/webdevtools/archive/2008/08/13/debugging-a-website-with-a-host-header.aspx
And here's the recommended registry workaround: http://support.microsoft.com/kb/896861
Do yourself a favour and download IIS Admin .NET.
This handy little tool allows you to switch between your websites at a snip - each one will become localhost when activated, and crucially, get you out of this debug debacle.
http://www.codeplex.com/iisadmin
You do have to add the hostname to a value within the registry.. but I can't remember where.
Since you can only have one website running at a time, why don't you just have them all running as 'localhost'? This way you don't have to change any annoying registry settings but you still have your applications running in individual IIS Websites.

How can I copy files with ASP.Net using Vista and IIS7?

I have a button on a website that creates a directory and copys a file. I developed it using Visual Studio 2008, ASP.Net 3.5. I am running Vista as my OS. The website uses identiy impersonation.
The functionality doesn't work ("Access to Path XYZ is denied") when:
I run the website via IE hitting the local webserver
The functionality works fine when [note Visual Studio run with Admin rights]:
I hit play in Visual Studio
I say view in Browser from Visual Studio
I run the website via IE hitting the local webserver, but start IE with Admin rights
I deploy the website onto another webserver (also vista/IIS7)
I modify FireFox to accept integrated authentication, then access via FireFox and localhost
I've never seen this behavior before, previously File.Copy type commands only cared that the rights on the folder being copied to were valid etc... (I have Everyone having full control while trying to debug this situation). It seems likely that the issue is having Admin rights or not? Or being logged in to the machine that it is running on?
What is happening here? Why does it work in the development environment and deployed to another machine, but not work when deployed on my own machine? Seems very odd, any help would be appreciated.
EDIT: I've added "Everyone" to all of the relvant directories and give that user Full Control, so there shouldn't be any permission issues?
You should try giving permission to modify over asp.net
you can find several articles about that by google(ing) it.
More likely the user that IIS is running impersonated thread under does not have access to the original file or the destination. Have you tried doing the copy directly as that user? When you run IE as administrator or running VS as administrator the impersonated user has full rights as admin.
[Edit - add link]
There is some info on a similar thread, the idea to use SysInternals was good:
UnauthorizedAccessException with IIS7
OK I have tracked down the solution to this issue given these symptoms. I'm not 100% sure why this works (particularly since it works fine in FireFox and works fine in IE if you not connecting locally), but the following seems to be a work-around.
In IE select Tools -> Internet Options -> Security -> Trusted Sites -> Sites and add http://localhost as a trusted site. This then enables you to use the website locally. Why you need to do this in IE when connecting locally and not in FireFox or IE when connecting to another machine is something I don't know. But it does seem to be a viable workaround.
My guess is the identity ASP.Net is running under doesn't have permissions (NetworkService) or the user used for anonymous authentication does have permission (IUSR)

NAntContrib/NAnt mkiisdir fails on IIS 7.0 / windows 2008

I'm trying to use NAnt/NAntContrib build script to build a web application on Windows 2008 (IIS 7.0).
In the build file, there is mkiisdir task, which fails with:
[mkiisdir] The webservice at 'localhost' does not exist or is not reachable.
All the documents/posts I found so far (non for w2k8, only Vista) say to install IIS 6 Compatibility services (all of them, including scripting tools, etc.) So I did, but it still throws this error.
Any idea what else need to be changes, so NAnt be able to create/delete virtual directories on IIS 7.0?
EDIT: New data - when I log in as local administrator to this server, the nant task succeeds, but it fails when I log in as a domain admin. I have added the domain admins group in the local Administrators group, but it still fails. Any idea what other permissions I need to check/change in order to make my domain admin user to be able to execute this task? I can create manually virtual folders without any problems.
In order to get iis nantcontrib tasks to work you need to install IIS6 Management Compatibility Tools. Here is the blog describing how to do it in Vista:
http://thoughtworker.in/2008/01/15/nant-the-webservice-at-localhost-does-not-exist-or-is-not-reachable/
Here is a screenshot of how to do it in Windows Server 2008:
alt text http://img407.imageshack.us/img407/699/iis6tools.png
To answer my own question - I have isolated the part of the code in NantContrib which was causing the problem, and made a sample application to test.
I have posted this as a separate question here, and there is the solution as well.
Cheers

Resources