Search Results

Search found 806 results on 33 pages for 'httpcontext'.

Page 2/33 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • ASP.NET MVC unit test controller with HttpContext

    - by user299592
    I am trying to write a unit test for my one controller to verify if a view was returned properly, but this controller has a basecontroller that accesses the HttpContext.Current.Session. Everytime I create a new instance of my controller is calls the basecontroller constructor and the test fails with a null pointer exception on the HttpContext.Current.Session. Here is the code: public class BaseController : Controller { protected BaseController() { ViewData["UserID"] = HttpContext.Current.Session["UserID"]; } } public class IndexController : BaseController { public ActionResult Index() { return View("Index.aspx"); } } [TestMethod] public void Retrieve_IndexTest() { // Arrange const string expectedViewName = "Index"; IndexController controller = new IndexController(); // Act var result = controller.Index() as ViewResult; // Assert Assert.IsNotNull(result, "Should have returned a ViewResult"); Assert.AreEqual(expectedViewName, result.ViewName, "View name should have been {0}", expectedViewName); } Any ideas on how to mock the Session that is accessed in the base controller so the test in the descendant controller will run?

    Read the article

  • attaching linq to sql datacontext to httpcontext in business layer

    - by rap-uvic
    Hello all, I need my linq to sql datacontext to be available across my business/data layer for all my repository objects to access. However since this is a web app, I want to create and destroy it per request. I'm wondering if having a singleton class that can lazily create and attach the datacontext to current HttpContext would work. My question is: would the datacontext get disposed automatically when the request ends? Below is the code for what I'm thinking. Would this accomplish my purpose: have a thread-safe datacontext instance that is lazily available and is automatically disposed when the request ends? public class SingletonDC { public static NorthwindDataContext Default { get { NorthwindDataContext defaultInstance = (NorthwindDataContext)System.Web.HttpContext.Current.Items["datacontext"]; if (defaultInstance == null) { defaultInstance = new NorthwindDataContext(); System.Web.HttpContext.Current.Items.Add("datacontext", defaultInstance); } return defaultInstance; } } }

    Read the article

  • Are there any nasty side affects if i lock the HttpContext.Current.Cache.Insert method

    - by Ekk
    Apart from blocking other threads reading from the cache what other problems should I be thinking about when locking the cache insert method for a public facing website. The actual data retrieval and insert into the cache should take no more than 1 second, which we can live with. More importantly i don't want multiple thread potentially all hitting the Insert method at the same time. The sample code looks something like: public static readonly object _syncRoot = new object(); if (HttpContext.Current.Cache["key"] == null) { lock (_syncRoot) { HttpContext.Current.Cache.Insert("key", "DATA", null, DateTime.Now.AddMinutes(5), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } } Response.Write(HttpContext.Current.Cache["key"]);

    Read the article

  • Asp.net Mvc - Kigg: Maintain User object in HttpContext.Items between requests.

    - by Pickels
    Hallo, first I want to say that I hope this doesn't look like I am lazy but I have some trouble understanding a piece of code from the following project. http://kigg.codeplex.com/ I was going through the source code and I noticed something that would be usefull for my own little project I am making. In their BaseController they have the following code: private static readonly Type CurrentUserKey = typeof(IUser); public IUser CurrentUser { get { if (!string.IsNullOrEmpty(CurrentUserName)) { IUser user = HttpContext.Items[CurrentUserKey] as IUser; if (user == null) { user = AccountRepository.FindByClaim(CurrentUserName); if (user != null) { HttpContext.Items[CurrentUserKey] = user; } } return user; } return null; } } This isn't an exact copy of the code I adjusted it a little to my needs. This part of the code I still understand. They store their IUser in HttpContext.Items. I guess they do it so that they don't have to call the database eachtime they need the User object. The part that I don't understand is how they maintain this object in between requests. If I understand correctly the HttpContext.Items is a per request cache storage. So after some more digging I found the following code. internal static IDictionary<UnityPerWebRequestLifetimeManager, object> GetInstances(HttpContextBase httpContext) { IDictionary<UnityPerWebRequestLifetimeManager, object> instances; if (httpContext.Items.Contains(Key)) { instances = (IDictionary<UnityPerWebRequestLifetimeManager, object>) httpContext.Items[Key]; } else { lock (httpContext.Items) { if (httpContext.Items.Contains(Key)) { instances = (IDictionary<UnityPerWebRequestLifetimeManager, object>) httpContext.Items[Key]; } else { instances = new Dictionary<UnityPerWebRequestLifetimeManager, object>(); httpContext.Items.Add(Key, instances); } } } return instances; } This is the part where some magic happens that I don't understand. I think they use Unity to do some dependency injection on each request? In my project I am using Ninject and I am wondering how I can get the same result. I guess InRequestScope in Ninject is the same as UnityPerWebRequestLifetimeManager? I am also wondering which class/method they are binding to which interface? Since the HttpContext.Items get destroyed each request how do they prevent losing their user object? Anyway it's kinda a long question so I am gradefull for any push in the right direction. Kind regards, Pickels

    Read the article

  • How to use HttpContext.Current on asynchronous threads?

    - by Eran Betzalel
    I've a schedule tasks mechanism (very similar to DotNetNuke's) in my business logic library (a DLL that is used by ASP.Net website). When I use HttpContext.Current inside on of these tasks, it returns with a null value, because the current async thread (or task) was not initiated from a user's request. How can I use HttpContext.Current in these asynchronous threads? P.S - I think my question is more best-practices related than technical.

    Read the article

  • HttpContext returning only "/"

    - by user281180
    I have the following two lines of codes in my model, however, both virtual and path have values "\". Where have I gone wrong? var virtual = VirtualPathUtility.ToAbsolute(HttpContext.Current.Request.ApplicationPath); var path =HttpContext.Current.Request.ApplicationPath;

    Read the article

  • Performance Difference between HttpContext user and Thread user

    - by atrueresistance
    I am wondering what the difference between HttpContext.Current.User.Identity.Name.ToString.ToLower and Thread.CurrentPrincipal.Identity.Name.ToString.ToLower. Both methods grab the username in my asp.net 3.5 web service. I decided to figure out if there was any difference in performance using a little program. Running from full Stop to Start Debugging in every run. Dim st As DateTime = DateAndTime.Now Try 'user = HttpContext.Current.User.Identity.Name.ToString.ToLower user = Thread.CurrentPrincipal.Identity.Name.ToString.ToLower Dim dif As TimeSpan = Now.Subtract(st) Dim break As String = "nothing" Catch ex As Exception user = "Undefined" End Try I set a breakpoint on break to read the value of dif. The results were the same for both methods. dif.Milliseconds 0 Integer dif.Ticks 0 Long Using a longer duration, loop 5,000 times results in these figures. Thread Method run 1 dif.Milliseconds 125 Integer dif.Ticks 1250000 Long run 2 dif.Milliseconds 0 Integer dif.Ticks 0 Long run 3 dif.Milliseconds 0 Integer dif.Ticks 0 Long HttpContext Method run 1 dif.Milliseconds 15 Integer dif.Ticks 156250 Long run 2 dif.Milliseconds 156 Integer dif.Ticks 1562500 Long run 3 dif.Milliseconds 0 Integer dif.Ticks 0 Long So I guess what is more prefered, or more compliant with webservice standards? If there is some type of a performance advantage, I can't really tell. Which one scales to larger environments easier?

    Read the article

  • ASP.NET HttpContext.GetLocalResourceObject() throws InvalidOperationException

    - by Dylan Lin
    Hi all, Let's say we have such site structure: App_LocalResources       |- A.aspx.resx       |- B.aspx.resx A.aspx B.aspx Now I use HttpContext.GetLocalResourceObject("~/A.aspx") in A.aspx.cs, and it works fine. But if I use HttpContext.GetLocalResourceObject("~/A.aspx") in B.aspx.cs, it throws an exception: The resource class for this page was not found. Please check if the resource file exists and try again. Exception Details: System.InvalidOperationException: The resource class for this page was not found. Please check if the resource file exists and try again. How can I resolve this problem? I want to read the local resources from an external page, and I don't want to read the .resx file myself. Thanks :-)

    Read the article

  • Storing extended IIdentity in HttpContext.Current.User (IPrinciple)

    - by UpTheCreek
    I have created an ExtendedId class which extends GenericIdentity. (This stores Id as well as name) In a httpmodule I stored this extended id in Current.User like so: HttpContext.Current.User = new GenericPrincipal(myExtendedId, roles); Problem is, later, how do I get at my ExtendedId type again? If I try this: ExtendedId eId = (ExtendedId)HttpContext.Current.User.Identity; I get a casting error. I have a feeling I'm doing something stupid here with casting, but I'm a bit foggy this morning.

    Read the article

  • Safe HttpContext.Current.Cache Usage

    - by Burak SARICA
    Hello there, I use Cache in a web service method like this : var pblDataList = (List<blabla>)HttpContext.Current.Cache.Get("pblDataList"); if (pblDataList == null) { var PBLData = dc.ExecuteQuery<blabla>( @"SELECT blabla"); pblDataList = PBLData.ToList(); HttpContext.Current.Cache.Add("pblDataList", pblDataList, null, DateTime.Now.Add(new TimeSpan(0, 0, 15)), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } I wonder is it thread safe? I mean the method is called by multiple requesters And more then one requester may hit the second line at the same time while the cache is empty. So all of these requesters will retrieve the data and add to cache. The query takes 5-8 seconds. May a surrounding lock statement around this code prevent that action? (I know multiple queries will not cause error but i want to be sure running just one query.)

    Read the article

  • Wanna use StructureMap to store HttpContext/User based explicit instances

    - by René
    Hi I'm having difficulty figuring out how to store an explicitly user generated instance in StructureMap, cached by HttpContext. When I try the code underneath, I even get the first cached instance, which leads to failures when using it for storing user credentials in Asp.Net AuthenticateRequest method. ForRequestedType<TInterface>() .CacheBy(InstanceScope.HttpContext) .TheDefault. Is. Object(instance)); The problem is I can't create a new instance on requesting StructureMap, because I need more other factories for getting rights etc. for the current user. Any ideas?

    Read the article

  • Change HttpContext.Request.InputStream

    - by user320478
    I am getting lot of errors for HttpRequestValidationException in my event log. Is it possible to HTMLEncode all the inputs from override of ProcessRequest on web page. I have tried this but it gives context.Request.InputStream.CanWrite == false always. Is there any way to HTMLEncode all the feilds when request is made? public override void ProcessRequest(HttpContext context) { if (context.Request.InputStream.CanRead) { IEnumerator en = HttpContext.Current.Request.Form.GetEnumerator(); while (en.MoveNext()) { //Response.Write(Server.HtmlEncode(en.Current + " = " + //HttpContext.Current.Request.Form[(string)en.Current])); } long nLen = context.Request.InputStream.Length; if (nLen > 0) { string strInputStream = string.Empty; context.Request.InputStream.Position = 0; byte[] bytes = new byte[nLen]; context.Request.InputStream.Read(bytes, 0, Convert.ToInt32(nLen)); strInputStream = Encoding.Default.GetString(bytes); if (!string.IsNullOrEmpty(strInputStream)) { List<string> stream = strInputStream.Split('&').ToList<string>(); Dictionary<int, string> data = new Dictionary<int, string>(); if (stream != null && stream.Count > 0) { int index = 0; foreach (string str in stream) { if (str.Length > 3 && str.Substring(0, 3) == "txt") { string textBoxData = str; string temp = Server.HtmlEncode(str); //stream[index] = temp; data.Add(index, temp); index++; } } if (data.Count > 0) { List<string> streamNew = stream; foreach (KeyValuePair<int, string> kvp in data) { streamNew[kvp.Key] = kvp.Value; } string newStream = string.Join("", streamNew.ToArray()); byte[] bytesNew = Encoding.Default.GetBytes(newStream); if (context.Request.InputStream.CanWrite) { context.Request.InputStream.Flush(); context.Request.InputStream.Position = 0; context.Request.InputStream.Write(bytesNew, 0, bytesNew.Length); //Request.InputStream.Close(); //Request.InputStream.Dispose(); } } } } } } base.ProcessRequest(context); }

    Read the article

  • What is my HttpContext.GetLocalResourceObject Method Virtual Path?

    - by ARUNRAJ
    I have read http://msdn.microsoft.com/en-us/library/ms149953.aspx and need to verify what is my GetLocalResourceObject virtual path. My local resource files are located on my pc at: C:\inetpub\wwwroot\GlobalX\Input\App_LocalResources Within this folder are my resource files for all the languages that site handles (InputContactDetails.aspx.ro.resx, InputContactDetails.aspx.hi.resx, etc.), as well as the default resource file (InputContactDetails.aspx.resx). I am receiving an error when I attempt to implement the virtual path string. Below is my line of offending code: return '<%= HttpContext.GetLocalResourceObject("~/GlobalX/Input/App_LocalResources/InputContactDetails.aspx.resx", "ContactDetails.Text", new System.Globalization.CultureInfo("ro")) %>'; I have tried ~/GlobalX/Input/App_LocalResources as the virtual path, and several other permutations, but I get the same error. If someone could show what I am doing wrong, I would appreciate it greatly. Here is the error message I am getting: The resource class for this page was not found. Please check if the resource file exists and try again. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: The resource class for this page was not found. Please check if the resource file exists and try again. Source Error: Line 410: function languageContactPromptPhone(var_lcs) { Line 411: if (var_lcs == "af") { Line 412: return '<%= HttpContext.GetLocalResourceObject("~/GlobalX/Input/App_LocalResources/InputContactDetails.aspx.resx", "ContactDetails.Text", new System.Globalization.CultureInfo("ro")) %'; Line 413: } Line 414: else if (var_lcs == "sq") { Source File: c:\inetpub\wwwroot\GlobalX\Input\InputContactDetails.aspx Line: 412 Stack Trace: [InvalidOperationException: The resource class for this page was not found. Please check if the resource file exists and try again.] System.Web.Compilation.LocalResXResourceProvider.CreateResourceManager() +2785818 System.Web.Compilation.BaseResXResourceProvider.EnsureResourceManager() +24 System.Web.Compilation.BaseResXResourceProvider.GetObject(String resourceKey, CultureInfo culture) +15 System.Web.Compilation.ResourceExpressionBuilder.GetResourceObject(IResourceProvider resourceProvider, String resourceKey, CultureInfo culture, Type objType, String propName) +23 System.Web.HttpContext.GetLocalResourceObject(String virtualPath, String resourceKey, CultureInfo culture) +38 ASP.input_inputcontactdetails_aspx.__RenderContentInputContactDetails(HtmlTextWriter __w, Control parameterContainer) in c:\inetpub\wwwroot\GlobalX\Input\InputContactDetails.aspx:412 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +109 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8 System.Web.UI.Control.Render(HtmlTextWriter writer) +10 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +8991378 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8 System.Web.UI.Control.Render(HtmlTextWriter writer) +10 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +8991378 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208 System.Web.UI.UpdatePanel.RenderChildren(HtmlTextWriter writer) +256 System.Web.UI.UpdatePanel.Render(HtmlTextWriter writer) +37 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +8991378 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 ASP.masterpages_masterinput_master.__RenderformMasterInput(HtmlTextWriter __w, Control parameterContainer) in c:\inetpub\wwwroot\GlobalX\MasterPages\MasterInput.master:140 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +109 System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +173 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +31 System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +53 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +8991378 System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8 System.Web.UI.Control.Render(HtmlTextWriter writer) +10 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +8991378 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8 System.Web.UI.Page.Render(HtmlTextWriter writer) +29 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +8991378 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3060

    Read the article

  • Mocking HttpContext in .NET MVC2 using Moq

    - by Richard
    Hi, This was working in MVC 1, but has broken in MVC 2. I'm mocking the HttpContext so I can test routes. The code was originally taken from Steven Sanderson's book. I've tried mocking some extra properties as suggested in this comment but it hasn't fixed it. What am I missing? This is the start of my test code. routeData is null when this code completes. // Arange RouteCollection routeConfig = new RouteCollection(); MvcApplication.RegisterRoutes(routeConfig); var mockHttpContext = makeMockHttpContext(url); // Act RouteData routeData = routeConfig.GetRouteData(mockHttpContext.Object); This method creates my mock HttpContext: private static Mock<HttpContextBase> makeMockHttpContext(String url) { var mockHttpContext = new Mock<System.Web.HttpContextBase>(); // Mock the request var mockRequest = new Mock<HttpRequestBase>(); mockHttpContext.Setup(t => t.Request).Returns(mockRequest.Object); mockRequest.Setup(t => t.AppRelativeCurrentExecutionFilePath).Returns(url); // Tried adding these to fix in MVC2 (didn't work) mockRequest.Setup(r => r.HttpMethod).Returns("GET"); mockRequest.Setup(r => r.Headers).Returns(new NameValueCollection()); mockRequest.Setup(r => r.Form).Returns(new NameValueCollection()); mockRequest.Setup(r => r.QueryString).Returns(new NameValueCollection()); mockRequest.Setup(r => r.Files).Returns(new Mock<HttpFileCollectionBase>().Object); // Mock the response var mockResponse = new Mock<HttpResponseBase>(); mockHttpContext.Setup(t => t.Response).Returns(mockResponse.Object); mockResponse.Setup(t => t.ApplyAppPathModifier(It.IsAny<String>())).Returns<String>(t => t); return mockHttpContext; }

    Read the article

  • The cross-thread usage of "HttpContext.Current" property and related things

    - by smwikipedia
    I read from < Essential ASP.NET with Examples in C# the following statement: Another useful property to know about is the static Current property of the HttpContext class. This property always points to the current instance of the HttpContext class for the request being serviced. This can be convenient if you are writing helper classes that will be used from pages or other pipeline classes and may need to access the context for whatever reason. By using the static Current property to retrieve the context, you can avoid passing a reference to it to helper classes. For example, the class shown in Listing 4-1 uses the Current property of the context to access the QueryString and print something to the current response buffer. Note that for this static property to be correctly initialized, the caller must be executing on the original request thread, so if you have spawned additional threads to perform work during a request, you must take care to provide access to the context class yourself. I am wondering about the root cause of the bold part, and one thing leads to another, here is my thoughts: We know that a process can have multiple threads. Each of these threads have their own stacks, respectively. These threads also have access to a shared memory area, the heap. The stack then, as I understand it, is kind of where all the context for that thread is stored. For a thread to access something in the heap it must use a pointer, and the pointer is stored on its stack. So when we make some cross-thread calls, we must make sure that all the necessary context info is passed from the caller thread's stack to the callee thread's stack. But I am not quite sure if I made any mistake. Any comments will be deeply appreciated. Thanks. ADD Here the stack is limited to user stack.

    Read the article

  • HttpContext.Current.Request.Url.Host returns a string of numbers

    - by Jonathan Sewell
    I have a website that emails a link to the invoice when an order is complete. The link should be http://mysite.com/QuoteAndBook/Confirmation?orderId=123 But for some reason it is: http://204435-204435/QuoteAndBook/Confirmation?orderId=123 The host portion of the link is generated using HttpContext.Current.Request.Url.Host but I would expect that to return "mysite.com", not "204435-204435". Any idea what's going on?

    Read the article

  • OperationContext.Current is null and all other contexts too

    - by HeavyWave
    I have a WCF service defined as following: [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(IncludeExceptionDetailInFaults = true, InstanceContextMode = InstanceContextMode.PerCall)] public partial class FrontEndService : IFrontEndService However, most of the time (but not always -_-) InstanceContext.Current is null, as well as HttpContext.Current and OperationContext.Current is also null. What am I missing? What I want to do is store some data in HttpContext.Current.Items or a similar collection that exists for the length of the request.

    Read the article

  • Trying to update an MVC 1.0 project to MVC 2.0

    - by Cptcecil
    I'm trying to update my project to MVC 2.0 from MVC 1.0. I've removed the references for System.Web.MVC to the newer versions. I'm getting an exception from the HTTPContext which reads "CurrentNotification = 'HttpContext.Current.CurrentNotification' threw an exception of type 'System.PlatformNotSupportedException'". What other binaries do I need to update a reference to, to get my project to work again?

    Read the article

  • asp.net mvc compress stream and remove whitespace

    - by Bigfellahull
    Hi, So I am compressing my output stream via an action filter: var response = filterContext.HttpContext.Response; response.Filter = new DeflateStream(response.Filter), CompressionMode.Compress); Which works great. Now, I would also like to remove the excess whitespace present. I found Mads Kristensen's http module http://madskristensen.net/post/A-whitespace-removal-HTTP-module-for-ASPNET-20.aspx. I added the WhitespaceFilter class and added a new filter like the compression: var response = filterContext.HttpContext.Response; response.Filter = new WhitepaperFilter(response.Filter); This also works great. However, I seem to be having problems combining the two! I tried: var response = filterContext.HttpContext.Response; response.Filter = new DeflateStream(new WhitespaceFilter(response.Filter), CompressionMode.Compress); However this results in some major issues. The html gets completely messed up and sometimes I get an 330 error. It seems that the Whitespace filter write method gets called multiple times. The first time the html string is fine, but on subsequent calls its just random characters. I thought it might be because the stream had been deflated, but isnt the whitespace filter using the untouched stream and then passing the resulting stream to the DeflateStream call? Any ideas?

    Read the article

  • HttpContext XML values in XSLT

    - by Siva
    Hi all. Please Help me out. In C# i set a context value as HttpContext.Current.Items["xmlcontentholder"] = xDoc.DocumentElement.FirstChild.OuterXml; and by processing XsltArgumentList i send it to an XSLT file: XsltArgumentList XsltArgs = new XsltArgumentList(); XsltArgs.AddParam("xmlcontentholder", "", "xmlcontent"); and i m transforming it xsltCompiledTrans.Transform(xPathNav, XsltArgs, stringWriter); In XSLT file i gave as <xsl:value-of select="$xmlcontentholder" /><br/>12<xsl:value-of select="msxsl:node-set($xmlcontentholder)/ROW[1]/value" />34 My output is <ROW><value>1</value><value>2</value></ROW> 1234 Please explain me on this problem..

    Read the article

  • Problem with httpContext.RewritePath on IIS 7

    - by PNR
    I am using httpContext.RewritePath in Global.asax for som URLrewriting, and it works very well in my development environment on the Cassini server. But when I copy it to the production server, witch is a IIS 7 it isn't working. I have also tried to use Context.Server.TransferRequest but thne I get the error: "This operation requires IIS integrated pipeline mode." on both Cassini and IIS 7, and on IIS 7 the website is running in "Integreret" mode in the AppPool. I rewrite all urls on the website like /[The main menuname]/[pagename].aspx fx from /web/thesite.aspx?mainmenu=manager to /manager/thesite.aspx OR /web/theOtherSite.aspx?mainmenu=about to /about/theOtherSite.aspx And so on... Thanks very much in advance!

    Read the article

  • UrlHelper and ViewContext inside an Authorization Attribute

    - by DM
    I have a scenario that I haven't been able to solve: I'm toying around with creating my own custom authorization attribute for mvc. The main bit of functionality I would like to add is to have the ability to change where the user gets redirected if they are not in a certain role. I don't mind that the system sends them back to the login page if they're not authenticated, but I would like to choose where to send them if they are authenticated but not allowed to access that action method. Here's is what I would like to do: public class CustomAuthorizeAttribute : AuthorizeAttribute { public string Action; public string Controller; protected override bool AuthorizeCore(System.Web.HttpContextBase httpContext) { // if User is authenticated but not in the correct role string url = Url.Action(this.Action, this.Controller); httpContext.Response.Redirect(url); } } And as an added bonus I would like to have access to ViewContext and TempData before I do the redirect. Any thoughts on how I could get instantiate a UrlHelper and ViewContext in the attribute?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >