I'm wondering whether there's a way that I can instantiate an object or call a utility function that will simply take in an object and perhaps a path to a view as parameters, and return a string that consists of the rendered view, using the object as the model.   I don't want to go through the usual ASP.NET request pipeline, or deal with dependency injection or even depend on the framework running to provide a bunch of services.  I simply want an easy way to render a view to a string in code.   Does this exist?   If anyone knows of any good sources on how view rendering in ASP.NET works under the hood, that would also be very helpful.
I want to output two different views (one as a string that will be sent as an email), and the other the page displayed to a user.  Is this possible in ASP.NET MVC beta?  I've tried multiple examples:  1.      If I use this example, I receive the "Cannot redirect after HTTP   headers have been sent.".   2.      If I use this, I seem to be unable to do a redirectToAction, as it   tries to render a view that may not exist. If I do return the view, it   is completely messed up and doesn't look right at all.   Does anyone have any ideas/solutions to these issues i have, or have any suggestions for better ones?  Many thanks!  Below is an example. What I'm trying to do is create the GetViewForEmail method:  public ActionResult OrderResult(string ref) {     //Get the order     Order order = OrderService.GetOrder(ref);      //The email helper would do the meat and veg by getting the view as a string     //Pass the control name (OrderResultEmail) and the model (order)     string emailView = GetViewForEmail("OrderResultEmail", order);      //Email the order out     EmailHelper(order, emailView);     return View("OrderResult", order); }   Accepted answer from Tim Scott (changed and formatted a little by me):  public virtual string RenderViewToString(     ControllerContext controllerContext,     string viewPath,     string masterPath,     ViewDataDictionary viewData,     TempDataDictionary tempData) {     Stream filter = null;     ViewPage viewPage = new ViewPage();      //Right, create our view     viewPage.ViewContext = new ViewContext(controllerContext, new WebFormView(viewPath, masterPath), viewData, tempData);      //Get the response context, flush it and get the response filter.     var response = viewPage.ViewContext.HttpContext.Response;     response.Flush();     var oldFilter = response.Filter;      try     {         //Put a new filter into the response         filter = new MemoryStream();         response.Filter = filter;          //Now render the view into the memorystream and flush the response         viewPage.ViewContext.View.Render(viewPage.ViewContext, viewPage.ViewContext.HttpContext.Response.Output);         response.Flush();          //Now read the rendered view.         filter.Position = 0;         var reader = new StreamReader(filter, response.ContentEncoding);         return reader.ReadToEnd();     }     finally     {         //Clean up.         if (filter != null)         {             filter.Dispose();         }          //Now replace the response filter         response.Filter = oldFilter;     } }   Example usage  Assuming a call from the controller to get the order confirmation email, passing the Site.Master location.  string myString = RenderViewToString(this.ControllerContext, "~/Views/Order/OrderResultEmail.aspx", "~/Views/Shared/Site.Master", this.ViewData, this.TempData);
Does there exist a continuous function $\: f : \mathbf{R} \to \mathbf{R} \:$ such that for   all  functions $\: g : \mathbf{R} \to \mathbf{R} \:$, for all real numbers $x$,  there exists a real number $y$ such that $\: x &lt; y \:$ and $\: g(y) &lt; f(y) \:$? The essential gist of my question relates to what the real, unvarnished realities are of graduate, post-graduate, research, fellowship, and professorship attainment - when you aren't a single person with no pressing demands other than feeding yourself.   [EDIT: I am humbled by the incredibly helpful and thoughtful responses so far, all of which are +1 from me. I'll leave the question open a few more days before clicking 'accept' on any one, but you all have my gratitude and I hope others will benefit anywhere near as much as I have. ]  What I don't know is what succeeding in this path truly requires in time committment and family support.   Right now I can handle a 12-14 credit course schedule with 3.7-4.0 GPA (in the top 5-10% for college and program, dean's list, etc), work part-time, and still have time to be home and not have a burn-out/breakdown - and the academics are the easy part by far! I could do more, but I need to work more too.   What I really need to know is how sharply different is the time/dedication curve of graduate work and above. I realize each step is a filter that removes most of the entrants (most people don't get a degree, most who do don't attend/finish graduate school, most who do don't seek a PhD,  most who do don't seek/gain professorship...and on and on). But I don't know how severe the stepping is - I'm not talking "tenured professor at MIT or bust" - I realize that bar is many orders of magnitude higher.  Background Details: As an "adult, returning" undergraduate student with a (disabled) wife and kids, I'm halfway through a bachelor degree now. I've located a field of study (in a focus of Industrial Engineering) that has made me very interested in altering my life path to include seeking a Masters and maybe even a PhD/professorship (my father was a professor, so its not a purely novel concept to me). I've met and spoken with my advisor and 2 other professors with experience in related fields, and all is encouraging; I have a graduate school in mind, I've received lots of great advice on preparing for school (on this forum and in person), I test well (no GRE fears remain), good grades/class rank, good prospects for future strong referal letters, etc - a comparitively charmed existence for which I am very grateful! I just have to investigate whether I can make it through with an intact, cared for family!  Any guidance you could provide me, and other aspiring "non-traditional" students alike, would be appreciated immensely - thank you! Frequency of the sound when blowing in a bottle I'm sure you have tried sometime to make a sound by blowing in an empty bottle. Of course, the tone/frequency of the sound modifies if the bottle changes its shape, volume, etc.   I am interested in understanding how the tone/frequency of this sound can be (approximately) calculated from the shape of the bottle. Is there some formula?  If you have any references about this please post them in your answers.  Being a mathematician I keep hearing that the principal tone is given by the first eigenvalue of the Laplace operator, and I'd like to understand the physical explanation. How can I show only unnamed faces in Mac photos I was trying to show photos with unnamed faces so that I can annotate them. There is  but it requires you to mark all the pictures with no faces at all. Any suggestions? Ubuntu server: Cannot setup dummy driver alsa (LXC container) // modprobe issue $(\Bbb Z\oplus \Bbb Z)[X] \not\cong \Bbb Z[X]\oplus \Bbb Z[X]\,$? Well i tried to prove it but failed. They are both commutative and have the same set of units. So i can't see a property of one ring which the other ring does not possess. Thank you for any help. How can I turn on the Intel HD manually? For some weeks my MacBook 6.2 does not switch to the integrated graphics adapter (Intel HD). This is especially crucial when I work on battery (which happens quite often). I guess the runtime could be enhanced when it would take the HD adapter for display.  I checked that it automatically changes the graphics mode. I am running Snow Leopard 10.6.8.  I recently installed 8GiB RAM (not from Apple). Could this probably related to this issue? Actually I do not want to downgrade or use the expensive Apple RAM.  So, how can I manually turn on the internal graphics adapter? How do I make Firefox start always maximized? I am setting up Ubuntu with gnome for my grandma. How can I make firefox start ALWAYS maximized. What to do when witches appear early in the game? A long time ago I played an older version of Minecraft. Back then witches didn't spawn naturally, so you couldn't find them unless you found a hut. Now I'm playing again, but sometimes when I go down a cave I find one or two witches, and it's really hard to find them back.   So, what is the best you can do to kill witches, specially when two spawn at the same time and you don't have milk? problem with surfaces on tkz-fct i am using this wonderful tool that tkz-fct is for creating nice documents but I have a weird result from recently. This is my document :  \documentclass[10pt,a4paper]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{calc} \usepackage{color} \usepackage{pifont}                     %pour utiliser la police Ding \usepackage[left=1.5cm,right=1.5cm,top=2cm,bottom=2cm]{geometry} %marges du document \usepackage[french]{babel} \usepackage[usenames,dvipsnames]{xcolor} \usepackage[L]{thmbox} \usepackage{eurosym} \usepackage{enumitem}               %pour modifer itemize et enumerate \usepackage{amsmath,amsfonts,amssymb} \usepackage{mathrsfs}               %pour utiliser mathscr \usepackage{array,multirow,makecell} \usepackage{fancyhdr}               %package pour modifier les en-têtes \usepackage{fancybox}               %pour boîtes spéciales \usepackage{tikz,tkz-tab,tkz-fct} \usepackage{tikz-dependency}        %permet de créer des schemas \usepackage{sectsty}                %permet de modifier les styles des sections (voir \sectionfont l.21) \usepackage{fourier-orns} \usepackage{shadethm}               %pour theoremes en gris \setcellgapes{1pt} \makegapedcells \newcolumntype{R}[1]{&gt;{\raggedleft\arraybackslash }b{#1}}   %pour redéfinir les colonnes dans tabular \newcolumntype{L}[1]{&gt;{\raggedright\arraybackslash }b{#1}} \newcolumntype{C}[1]{&gt;{\centering\arraybackslash }b{#1}} \renewcommand{\thesection}{\Roman{section}} %permet de changer la numérotation en chiffres romains des sections \newshadetheorem{defi}{Définition}  %crée un nouveau type de théorème \newshadetheorem{thm}{Théorème} \newshadetheorem{ppte}{Propriété} \sectionfont{\sectionrule{3ex}{3pt}{-1.5ex}{1pt}} %mettre un trait de séparation dans les sections (package sectsty) \pagestyle{fancy} %style en-têtes \lhead{} %en-tête gauche \chead{Lois à densité} %en-tête centrale \rhead{T\up{ale}} %en-tête droite \begin{document} \begin{tikzpicture}      \tkzInit[xmin=-4,xmax=4,ymax=1]      \tkzDrawX[label={},noticks]      %\tkzDrawY      \tkzFct[domain=-2:2]{exp(-x**2)}      \tkzDrawArea[color=blue, domain = -0.5:1]      \tkzText(-1,0.75){$\mathscr{C}_{f}$} \end{tikzpicture} \end{document}   But from now, it doesn't produce the result I would like as the surface start from the point (-0.5,f(-0.5)) and not as an integral from -0.5 to 1. This is a picture of the result :   Which is obviously not what I would like and this extends now to all my "old" docs which were "normal" before. I don't think I have done anything special except updating my Tex distribution ... If someone has an idea ?? Integrating $\int_1^2 \int_0^ \sqrt{2x-x^2} \frac{1}{((x^2+y^2)^2} dydx $ in polar coordinates I'm having a problem converting $\int\limits_1^2  \int\limits_0^ \sqrt{2x-x^2}   \frac{1}{(x^2+y^2)^2}  dy dx $ to polar coordinates.  I drew the graph using my calculator, which looked like half a circle on the x axis.  I know that $\frac{1}{(x^2+y^2)^2}  dydx$ turns to $ \frac{r}{(r^2)^2}drd\theta$, which would be $ \frac{1}{r^3}$  The region of integration in  $\theta $ is I guess $0 \leq  \theta  \leq  \frac{1}{4}  \pi $, but I'm stuck for r. The lower boundary is $x=1=rcos\theta \rightarrow r=1/cos\theta=sec\theta$, but what is the upper boundary?? Is it  $\sqrt{2rcos\theta-r^2cos^2\theta}$? I tried this but I couldn't integrate my equation...  Could someone please help me out?  Also, how can I draw the graph of $y= \sqrt{2x-x^2} $? I could only know how it looked like by using my calculator... $\lim\limits_{n \to \infty} \frac{a_n}{b_n}=l$ ; Prove $\sum\limits_{k=1}^\infty a_k$ converges iff $\sum\limits_{k=1}^\infty b_k$ converges. Written, in Ex.8 Ch.9.1 of the book Advanced Calculus by P. M. Fitzpatrick :     Suppose that $\sum\limits_{k=1}^\infty a_k$ and $\sum\limits_{k=1}^\infty b_k$ are series of positive numbers such that $$\lim_{n \to \infty} \frac{a_n}{b_n}=l \ \ \ \text{and} \ l&gt;0.$$ Prove that the series $\sum\limits_{k=1}^\infty a_k$ converges iff the series $\sum\limits_{k=1}^\infty b_k$ converges.   Am I correct by the following (sketch of) proof? :  1- For a given $\epsilon_1$ there is $N_1$ such that $\left|\frac{a_n}{b_n} - l\right| &lt; \epsilon_1$ for all $n \ge N_1$.  2- Since the series $\sum\limits_{k=1}^\infty a_k$ converges, for a given $\epsilon_2$ there is $N_2$ such that $\left|b_{n+1}+\dots+b_{n+k}\right|&lt; \epsilon_1$ for all $n \ge N_2$ any for all natural numbers $k$.  3- Define $N = \max {\{N_1,N_2}\}$.   4- From Step (1), $a_{n+k} &lt; (\epsilon_1+l) b_{n+k}$ for all $n \ge N$ any for all natural numbers $k$. [Also, $a_i$'s and $b_i$'s are all positive]. Thus $a_{n+1}+\dots+a_{n+k} &lt; (\epsilon_1+l) (b_{n+1}+\dots+b_{n+k})&lt; \epsilon_3$. Then the convergence of the series $\sum\limits_{k=1}^\infty b_k$ implies the convergence of the series $\sum\limits_{k=1}^\infty a_k$.  5- For the reverse implication, we use the fact that $\lim\limits_{n \to \infty}\frac{a_n}{b_n}=l \iff \lim\limits_{n \to \infty}\frac{b_n}{a_n}= \frac{1}{l}= l' &gt;0$ and repeat the process this time for a and b exchanged.   6- The Quotient Property For Sequences hold for a nonzero limit in the denominator, but since the limit in the numerator also is zero so we may use the The Quotient Property For Sequences.    Thanks. Are there network-wide reputation leagues? I would love to see which people have the most network-wide reputation, how can I see that? How do you challenge the closing of one of your questions? As a newcomer to StackOverflow, I recently asked my first . I wanted to start with a fairly safe general question, to get the feel for how the site worked. My question was intended to be programming-related, but my original wording was not clear enough, so another user decided to close it.  I've re-phrased my question, and had received one useful answer before the question was closed, but I'm not sure what the procedure is after your question is closed to allow people to post answers again...  I've checked the FAQ and About pages, searched the SO questions, but have had no luck. Could someone point me in the right direction as to how I get my question re-opened, or if it is possible to do at all? Find all $n \in \mathbb{N}$ such that $\phi(n) = 4294967296=2^{32}$.  I managed to find that $16106127360$, $8589934592$, $10737418240$ and $12884901888$ are solutions for the equation, but I do not know how to find all of them. VMware Linux Server -- how can you tell if you are a vm or real hardware? Assume that a person (not me, I only hold a single citizenship :) has a double citizenship in countries such as the US, Singapore, Australia, Japan, etc, which are eligible for 90/180 visa-free stays in the Schengen area. Could they officially remain in the Schengen area indefinitely by taking a trip to (say) the UK every 89 days? Where do I place my own .sty or .cls files, to make them available to all my .tex files? I know how to define a package or a class, but how do I make it available (to myself) at all times?  Say I have the package file commonstuff.sty (or myprettyclass.cls), that I want to be able to include in any .tex file I create on my computer. Where do I put it? Do I need to run some installer on it, or is it enough to keep it in a certain folder?  Note: I know I can just place it in the same folder as the .tex file, but that's not what I'm after here. I'm looking for a way to "install" the package centrally on my computer. How do I display the nth result of an ls command? I used this command to display the first result of files in my directory.    ls | head -n 1   My simple question is, how can I modify this command to display say the nth result?  Thanks! Is there any way to include an animated GIF directly? Is there any way to include an animated GIF directly in either PDFLaTeX or XeLaTeX? I realize the animate package can include animations in a PDF, but it doesn't support animated GIFs and you have to split them up manually into EPS or PNG files as far as I can tell.