Search Results

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

Page 22/33 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • How to determine the pat of the current web site

    - by Velika2
    I wanted to create a function which would return the path of the current web site. This is what I thought was working while running in the IDE: Public Shared Function WebsiteAbsoluteBaseUrl() As String Dim RequestObject As System.Web.HttpRequest = HttpContext.Current.Request Return "http://" & RequestObject.Url.Host & ":" & _ RequestObject.Url.Port & "/" & _ RequestObject.Url.Segments(1) End Function Does this seem like it should work? Is there a more straight forward way?

    Read the article

  • Object reference error even when object is not null

    - by Shrewd Demon
    hi, i have an application wherein i have incorporate a "Remember Me" feature for the login screen. I do this by creating a cookie when the user logs in for the first time, so next time when the user visits the site i get the cookie and load the user information. i have written the code for loading user information in a common class in the App_Code folder...and all my pages inherit from this class. code for loading the user info is as follows: public static void LoadUserDetails(string emailId) { UsersEnt currentUser = UsersBL.LoadUserInfo(emailId); if (currentUser != null) HttpContext.Current.Session["CurrentUser"] = currentUser; } Now the problem is i get an "Object reference" error when i try to store the currentUser object in the session variable (even though the currentUser object is not null). However the password property in the currentUser object is null. Am i getting the error because of this...or is there some other reason?? thank you

    Read the article

  • XmlDocument caching memory usage

    - by mdsharpe
    We are seeing very high memory usage in .NET web applications which use XmlDocument. A small (~5MB) XML document is loaded into an XmlDocument object and stored in HttpContext.Cache for easy querying and XSLT transformation on each page load. The XML is modified on disk periodically so a cache has a dependency on the file. Such an application appears to be using hundreds of megabytes of RAM. I have experimented with requesting garbage collection on each request start, and this keeps the RAM usage far lower but I cannot imagine this is good practise. Does anyone have any suggestions as to how we can achieve the same goal but with lower RAM usage?

    Read the article

  • ASP.NET HTTPHandler not throwing exception when one is expected

    - by josephj1989
    I have an HttpHandler class (implements IHttphandler) where the path defined for the handler in web.config is *.jpg. I am requesting a Jpg image in my page. Within the HTTP Handler I am writing to a file in the filesystem. By mistake I was trying to write to a non existant directory. This should have thrown an exception but the execution simply proceeds.Ofcourse no file is written. But if I give a proper directory the file is written correctly.Is there anything special about HttpHandler Exceptions. See part of the code public void ProcessRequest(HttpContext context){ File.WriteAllLines(context.Request.ApplicationPath+@"\"+"resul.log",new string[]{"Entered JPG Handler"}); If I put a breakpoint on the File.WriteAllLines statement and then step over it I can see an exception occurring.

    Read the article

  • Scala and HttpClient: How do I resolve this error?

    - by Benjamin Metz
    I'm using scala with Apache HttpClient, and working through examples. I'm getting the following error: /Users/benjaminmetz/IdeaProjects/JakartaCapOne/src/JakExamp.scala Error:Error:line (16)error: overloaded method value execute with alternatives (org.apache.http.HttpHost,org.apache.http.HttpRequest)org.apache.http.HttpResponse <and> (org.apache.http.client.methods.HttpUriRequest,org.apache.http.protocol.HttpContext)org.apache.http.HttpResponse cannot be applied to (org.apache.http.client.methods.HttpGet,org.apache.http.client.ResponseHandler[String]) val responseBody = httpclient.execute(httpget, responseHandler) Here is the code with the error and line in question highlighted: import org.apache.http.client.ResponseHandler import org.apache.http.client.HttpClient import org.apache.http.client.methods.HttpGet import org.apache.http.impl.client.BasicResponseHandler import org.apache.http.impl.client.DefaultHttpClient object JakExamp { def main(args : Array[String]) : Unit = { val httpclient: HttpClient = new DefaultHttpClient val httpget: HttpGet = new HttpGet("www.google.com") println("executing request..." + httpget.getURI) val responseHandler: ResponseHandler[String] = new BasicResponseHandler val responseBody = httpclient.execute(httpget, responseHandler) // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ println(responseBody) client.getConnectionManager.shutdown } } I can successfully run the example in java...

    Read the article

  • Writing an image to ResponseBase.OutputStream does not work anymore with ASP.NET MVC2 RC2

    - by labilbe
    The following code worked nice on ASP.NET MVC1 public class ImageResult : ActionResult { public Image Image { get; set; } public override void ExecuteResult(ControllerContext context) { if (Image == null) { return; } HttpResponseBase response = context.HttpContext.Response; response.ContentType = "image/png"; Image.Save(response.OutputStream, ImageFormat.Png); } } I spent some time searching answers but I didn't find anyone. The error thrown is OutputStream is not available when a custom TextWriter is used.

    Read the article

  • How do I 'donut cache' in ASP.NET MVC for something more than a date

    - by Simon_Weaver
    All the examples for donut caching I've seen are just like this : <%= Html.Substitute( c => DateTime.Now.ToString() )%> Thats fine if I just want the date, but what other options are there? I know there is a delegate 'MvcSubstitutionCallback' which has the following signature : public delegate string MvcSubstitutionCallback(HttpContextBase httpContext); but RenderAction and RenderPartial returns void so i cant just return them from the delegate method. How can I effectively use this callback for more complex situations. I've looked at both of Phil Haacked's articles here and here, but neither seems to do exactly what I want.

    Read the article

  • deserialization on client sied in Domain Service

    - by ankit
    i have 2 classes. Person and Contact. Person class has property named "ContactNumber" which returns the Contact type, and this property is marked as "Datamember" for serialization. i have marked Contact type as "DAtaContract". on client side i am able to get the values, but when i try to insert a value and then do submit, i get the below exception. Failed to deserialize change-set. Failed to convert value of type 'Dictionary`2' to type 'Contact' Stack Trace is: at System.Web.Ria.DataServiceSubmitRequest.GetChangeSet(DomainService domainService) at System.Web.Ria.DataServiceSubmitRequest.Invoke(DomainService domainService) at System.Web.Ria.DataService.System.Web.IHttpHandler.ProcessRequest(HttpContext context) can anyone give me the solution ?

    Read the article

  • Deserialization on client side in Domain Service

    - by ankit
    I have 2 classes: Person and Contact. Person class has a property named ContactNumber which returns the Contact type, and this property is marked as a DataMember for serialization. I have marked Contact type as a DataContract. On the client side I am able to get the values, but when I try to insert a value and then do submit, I get the following exception: Failed to deserialize change-set. Failed to convert value of type 'Dictionary`2' to type 'Contact' Stack Trace is: at System.Web.Ria.DataServiceSubmitRequest.GetChangeSet(DomainService domainService) at System.Web.Ria.DataServiceSubmitRequest.Invoke(DomainService domainService) at System.Web.Ria.DataService.System.Web.IHttpHandler.ProcessRequest(HttpContext context) Can anyone give me the solution ?

    Read the article

  • how to check session upon start in masterpage or in global.asax

    - by user572276
    i am new in asp.net form authentication and sessions i would like to know how to save session in masterpage or in global.asax and how to clear session how to better handle session timeout by redirecting to a page this is my web.config session settings <sessionState mode="InProc" cookieless="false" timeout="1"></sessionState> code in my masterpage if (Request.Url.AbsolutePath.EndsWith("SessionExpired.aspx", StringComparison.InvariantCultureIgnoreCase)) { HtmlMeta meta = new HtmlMeta(); meta.HttpEquiv = "Refresh"; meta.Content = "7; URL=./Login.aspx"; Page.Header.Controls.Add(meta); } else HttpContext.Current.Response.AppendHeader("Refresh", Convert.ToString((Session.Timeout * 60)) + "; Url=./Public/SessionExpired.aspx");

    Read the article

  • ASP.NET MVC: Route to URL

    - by JamesBrownIsDead
    What's the easiest way to get the URL (relative or absolute) to a Route in MVC? I saw this code here on SO but it seems a little verbose and doesn't enumerate the RouteTable. Example: List<string> urlList = new List<string>(); urlList.Add(GetUrl(new { controller = "Help", action = "Edit" })); urlList.Add(GetUrl(new { controller = "Help", action = "Create" })); urlList.Add(GetUrl(new { controller = "About", action = "Company" })); urlList.Add(GetUrl(new { controller = "About", action = "Management" })); With: protected string GetUrl(object routeValues) { RouteValueDictionary values = new RouteValueDictionary(routeValues); RequestContext context = new RequestContext(HttpContext, RouteData); string url = RouteTable.Routes.GetVirtualPath(context, values).VirtualPath; return new Uri(Request.Url, url).AbsoluteUri; } What's a better way to examine the RouteTable and get a URL for a given controller and action?

    Read the article

  • Sending parameters to jquery callback

    - by KhanS
    I am making a jquery call from a javascript method. I want a parameter to be sent to my call back method. I am using a handler(ashx) to make jquery call, the handler is getting invoked by the callback is not getting fired. Below is the code function MyButtonClick(){ var myDiv = "divname"; $.post("MyHandler.ashx", { tgt: 1 }, myDiv, CustomCallBack); } function CustomCallBack(data, result) { debugger; //SomeCode } } Handler code(ashx file) public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int tgt = Convert.ToInt32(context.Request["tgt"]); if (tgt == 1) { context.Response.Write("Some text"); } }

    Read the article

  • How to determine the path of the current web site

    - by Velika2
    I wanted to create a function which would return the path of the current web site. This is what I thought was working while running in the IDE: Public Shared Function WebsiteAbsoluteBaseUrl() As String Dim RequestObject As System.Web.HttpRequest = HttpContext.Current.Request Return "http://" & RequestObject.Url.Host & ":" & _ RequestObject.Url.Port & "/" & _ RequestObject.Url.Segments(1) End Function Does this seem like it should work? Is there a more straight forward way?

    Read the article

  • Accessing HttpRequest from Global.asax via a page

    - by Polymorphix
    I'm trying to get a property (ImpersonatePersonId) from a page in global.asax but get a HttpException saying 'Request is not available in this context'. I've been searching for some documentation on where in the pipeline the request is accessible, but as far as I can see all Microsoft can produce of documentation is one-liners like "PostRequestHandlerExecute: Occurs when the ASP.NET event handler finishes execution." which really doesn't give me much... I've tried placing the call in both Pre and PostRequestHandlerExceute but with the same result. I wonder if anyone with experience in this would be so kind as to tell me where the Request object is available. My code from global asax is below. ICanImpersonate page = HttpContext.Current.Handler as ICanImpersonate; ImpersonatedUser impersonatePerson = page != null ? page.ImpersonatePersonId : null; Response.Filter = new TagRewriter(Response, new TagProcessor(Context, impersonatePerson).Process); What I want to do is rewrite some HTML based on some request parameters.

    Read the article

  • Calling a WCF from ASP.NET with same the single-signon user LogonUserIdentity

    - by Dennis Cheung
    I have a ASP.NET MVC page, which call WCF logic. The system is single-signon using NTML. Both the ASP page and the WCF will use the UserIdentity to get user login information. Other then NTML, I will also have a Form based authorization (with AD) in same system. The ASP page, is it simple and I can have it from HttpContext.Current.Request.LogonUserIdentity. However, it seem it is missing from the WCF which call by the ASP, not from browser. How to configure to pass the ID pass from the ASP to the WCF?

    Read the article

  • How to debug a WCF Service with an HTTP Context?

    - by JL
    I need to debug a WCF service but it needs to have an HTTP Context. Currently I have a solution with a WCF service web site, when I click on debug it starts up and then fires up an html page that contains no test form. While the project is running I tried starting the wcftestclient manually, then provided the address of my service, it finds the service but when I invoke it, it bypasses the IIS layer (or development server), so the httpContext is null... What is the correct way to debug a WCF service through an IIS context?

    Read the article

  • How can I utilize or mimic Application OnStart in an HttpModule?

    - by Sailing Judo
    We are trying to remove the global.asax from our many web applications in favor of HttpModules that are in a common code base. This works really well for many application events such as BeginRequest and PostAuthentication, but there is no Application Start event exposed in the HttpModule. I can think of a couple of smelly ways to overcome this deficit. For example, I can probably do this: protected virtual void BeginRequest(object sender, EventArgs e) { Log.Debug("Entered BeginRequest..."); var app = HttpContext.Current.Application; var hasBeenSet app["HasBeenExecuted"] == null ? false : true; if(!hasBeenSet) { app.Lock(); // ... do app level code app.Add("HasBeenSet", true); app.Unlock(); } // do regular begin request stuff ... } But this just doesn't smell well to me. What is the best way to invoke some application begin logic without having a global.asax?

    Read the article

  • Javascript culture always en-us

    - by LoveMeSomeCode
    I'm not sure if I understand this code or if I'm using it right, but I was under the impression that in an ASP.NET 2.0 AJAX website I could run javascript like: var c = Sys.CultureInfo.CurrentCulture and it would give me the culture/language settings the user had specified in their browser at the time of the visit. However, for me, it always comes back 'en-US' no matter what language I pick in firefox or IE. This serverside code however: string[] languages = HttpContext.Current.Request.UserLanguages; if (languages == null || languages.Length == 0) return null; try { string language = languages[0].ToLowerInvariant().Trim(); return CultureInfo.CreateSpecificCulture(language); } catch (ArgumentException) { return null; } does return the language I have currently set. But I need to do this clientside, because I need to parse a string into a datetime and do some validations before I postback, and the string could be a MM/DD/YYYY or DD/MM/YYYY, or some other such thing. What am I missing?

    Read the article

  • How can I change or remove HttpRequest input arguments in a HttpModule

    - by Eric Gunn
    Is it possible to change or remove http request form inputs in an httpmodule? My goal is to create a security IHttpmodule that will check the request for reasonable values, such as limits on acceptable input and query parameter length, or use the AntiXSS Sanitizer to remove threats, log potential hack attempts, etc. before a request is passed on to a processor. Because this is a cross cutting concern I'd prefer to find a solution that applies to all requests and affects all ways request values could be accessed, Reqest.Form, Action(model), Action(FormCollection), HttpContext.Current.Request.Form, etc. I'm using MVC and have considered creating custom model binders to clean the data before creating the model instance. But that would be application specific, require remembering to register every model binder and only apply to Action(model).

    Read the article

  • GlassFish JDO and global object

    - by bach
    Hi, I'm thinking about the GlassFish platform for my new app. My app env. doesn't have a big volume of data to handle, but a lot of users writing/reading the same data A very volotile portion of the data updates every 200milsec by diff users. Therefore I'd like that type of data to be in memory only and accessible to the whole app My questions: How do I use a global object in memory with GF? a. use a static variable object - for that I guess I need to make sure GF is running on only 1 JVM -- how to I configure GF to run on 1 jvm? b. use HttpContext - same as a. How do I persist to the DB? a. can I use JDO interface? How do I Schedule tasks to be performed in the future (something like the task queue in GAE) thanks, J.S. Bach

    Read the article

  • Caching the response of an ASP.NET HTTP Handler server and client side

    - by Bert Vandamme
    Is it possible to cache the response of a http handler on the server and on the client? This doesn't seem to be doing the trick: _context.Response.Cache.SetCacheability(HttpCacheability.Public); _context.Response.Cache.SetExpires(DateTime.Now.AddDays(7)); The _context is the HTTPContext passed as an argument to the ProcessRequest method on the IHttpHandler implementation. Any ideas? Update: The client does cache images that are loaded through the httphandler, but if another client does the same call, the server hasn't got it cached. So for each client that asks for the image, the server goes to the database (and filestream). If we use a aspx page instead of a httphandler together with a caching profile, then the images are cached both on the client and the server.

    Read the article

  • Strange Error - "Object moved to here."

    - by Dkong
    I get the strange error "Object moved to here." on a blank white page when I try to login on a site I created. It works fine locally but not when I deploy it to the test or production server. I am not doing anything odd, just using basic authentication code in a helper function as follows... public static bool AuthenticateUser(string Username, string Password, bool PersistLogin, string RedirectionURL) { if (Membership.ValidateUser(Username, Password)) { FormsAuthentication.SetAuthCookie(Username, PersistLogin); HttpContext.Current.Response.Redirect(RedirectionURL,true); return true; } else return false; }

    Read the article

  • Create LINQ to entities OrderBy expression on the fly

    - by AyKarsi
    I'm trying to add the orderby expression on the fly. But when the query below is executed I get the following exception: System.NotSupportedException: Unable to create a constant value of type 'Closure type'. Only primitive types ('such as Int32, String, and Guid') are supported in this context. The strange thing is, I am query exactly those primitive types only. string sortBy = HttpContext.Current.Request.QueryString["sidx"]; ParameterExpression prm = Expression.Parameter(typeof(buskerPosting), "posting"); Expression orderByProperty = Expression.Property(prm, sortBy); // get the paged records IQueryable<PostingListItemDto> query = (from posting in be.buskerPosting where posting.buskerAccount.cmsMember.nodeId == m.Id orderby orderByProperty //orderby posting.Created select new PostingListItemDto { Set = posting }).Skip<PostingListItemDto>((page - 1) * pageSize).Take<PostingListItemDto>(pageSize); Hope somebody can shed some light on this!

    Read the article

  • Newbie question on MvcContrib TestHelpers

    - by Simon Lomax
    Hi, I'm just starting to use the TestHelpers in MvcContrib. I want to try and test an action method on my controller that itself tests if IsAjaxRequest() is true. I've used the same code that is shown in the TestHelper samples to set up the TestControllerBuilder _controller = new StarsController(); _builder = new TestControllerBuilder(); _builder.InitializeController(_controller); So that _controller has all the faked/mocked HttpContext inside it, which is really great. But what do I do now to force IsAjaxRequest() on the internally faked Request object to return true?

    Read the article

  • Best ASP.NET Background Service Implementation

    - by Jason N. Gaylord
    What's the best implementation for more than one background service in an ASP.NET application? Timer Callback Timer timer = new Timer(new TimerCallback(MyWorkCallback), HttpContext, 5000, 5000); Thread or ThreadPool Thread thread = new Thread(Work); thread.IsBackground = true; thread.Start(); BackgroundWorker BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler(DoMyWork); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(DoMyWork_Completed); worker.RunWorkerAsync(); Caching like http://www.codeproject.com/KB/aspnet/ASPNETService.aspx (located in Jeff Atwood's post here) I need to run multiple background "services" at a given time. One service may run every 5 minutes where another may be once a day. It will never be more than 10 services running at a time.

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >