-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using MvcMailer from a WCF service #44
Comments
Thanks Spencer. I will consider this. Sent from my iPhone On 2012-04-16, at 6:41 AM, Spencer Drager
|
I tried to make this implementation. But i stuck in the beginning itself, has i couldn't find the source code for MVC Mailer (Can you share the link where i can find this) and will you pls elaborate this in steps... |
The source code is on github. Sent from my iPhone On 2012-12-20, at 4:14 AM, Thejraj notifications@github.com wrote: I tried to make this implementation. But i stuck in the beginning itself, — |
Not sure what to with the CreateControllerContext() and where. Do you have example of it? I downloaded the source code but not sure where to look for the WCF implementation. Please advice! Here is the test project that I have created: http://sdrv.ms/101uaPX |
Hi, I can't user ViewBag, getting error as "The name 'ViewBag' does not exist in the current context", is there any fix for this? |
@smdrager Thanks, its just works like a blaze. Although I had to add You forgot to mention the thing about ControllerContext on your Stackoverflow answer. |
@shishirkushwaha Glad I was of assistance. I didn't mention the part in this Github issue since it was linked to in the question. I wished by now the MvcMailer authors had implemented this change since there is no downside. Happy email sending! |
Hello, I wanted to use MvcMailer from a WCF service, and found only a small modification to MvcMailer helped this along dramatically. I wanted to share it with you, as I do not have an easy way to submit my changes.
WCF services have access to an HttpContext when
aspNetCompatibilityEnabled="true"
in the Web.config and the following attribute is added to the service class:After that, the only issue with MvcMailer is that it wanted to have a routing table for the ControllerContext constructor. Rather than try to fake this, we can use a different ControllerConext constructor which only requires an HttpRequest and the ControllerBase.
So if you modify the MailerBase.CreateControllerContext() method as such, you can then use MvcMailer in an WCF service.
There doesn't seem to be any drawbacks to using this alternative constructor, since MvcMailer doesn't use the routing table anyway.
I'd like to see this worked into a future release since it solves some issues with using MvcMailer and WCF (which really is a great way to separate your email from your project!).
Thanks
The text was updated successfully, but these errors were encountered: