Search Results

Search found 18677 results on 748 pages for 'current'.

Page 77/748 | < Previous Page | 73 74 75 76 77 78 79 80 81 82 83 84  | 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

  • working with generic lifetime managers in unity config section

    - by Martin Bailey
    I have the following generic lifetime manager public class RequestLifetimeManager<T> : LifetimeManager, IDisposable { public override object GetValue() { return HttpContext.Current.Items[typeof(T).AssemblyQualifiedName]; } public override void RemoveValue() { HttpContext.Current.Items.Remove(typeof(T).AssemblyQualifiedName); } public override void SetValue(object newValue) { HttpContext.Current.Items[typeof(T).AssemblyQualifiedName] = newValue; } public void Dispose() { RemoveValue(); } } How do I reference this in the unity config section. Creating a type alias <typeAlias alias="requestLifeTimeManager`1" type=" UI.Common.Unity.RequestLifetimeManager`1, UI.Common" /> and specifying it as a lifetime manager <types> <type type="[interface]" mapTo="[concretetype]" > <lifetime type="requestLifeTimeManager`1" /> </type> </types> causes the following error Cannot create an instance of UI.Common.Unity.RequestLifetimeManager`1[T] because Type.ContainsGenericParameters is true. How do you reference generic lifetime managers ?

    Read the article

  • Reading HttpURLConnection InputStream - manual buffer or BufferedInputStream?

    - by stormin986
    When reading the InputStream of an HttpURLConnection, is there any reason to use one of the following over the other? I've seen both used in examples. Manual Buffer: while ((length = inputStream.read(buffer)) > 0) { os.write(buf, 0, ret); } BufferedInputStream is = http.getInputStream(); bis = new BufferedInputStream(is); ByteArrayBuffer baf = new ByteArrayBuffer(50); int current = 0; while ((current = bis.read()) != -1) { baf.append(current); } EDIT I'm still new to HTTP in general but one consideration that comes to mind is that if I am using a persistent HTTP connection, I can't just read until the input stream is empty right? In that case, wouldn't I need to read the message length and just read the input stream for that length? And similarly, if NOT using a persistent connection, is the code I included 100% good to go in terms of reading the stream properly?

    Read the article

  • jquery attr problem

    - by shanmugam
    function rotateimg(ulid,showid,linkid) { var cur = $("#"+ulid+" li.current"); var nxt = cur.next("li"); if (nxt.length == 0) { nxt = $("#"+ulid+" li:first"); } cur.removeClass("current"); nxt.addClass("current"); var img_value=nxt.attr("id").substring(11); var img_title=nxt.attr("title"); var img_id = nxt.attr("name").substring(17); var alink=nxt.attr("rel"); $("#"+linkid).attr("href",alink); $("#"+ulid+" li div").css("background-color", "#000000"); nxt.find("div").css("background-color", "#333333"); setimg(img_value,showid,img_title); } var lt=setInterval("rotateimg('lnews','show_images_event','lnewslink')", 5000); in this code. i am getting this error nxt.attr("id") is undefined pls any one help me

    Read the article

  • hp -ux remote cpio copy

    - by soField
    REMOTE SERVER remsh remoteserverhostname -l remoteusername find /tmp/a1/ | cpio -o > /tmp/paketr.cpio LOCAL SERVER rcp remoteserverhostname:/tmp/paketr.cpio /tmp/aaa cpio -idmv < /tmp/paketr.cpio i'am trying to get and create directory structure from remote server to local server i can do this with following command list but i wonder if i can do this with just one command by running cpio with pass-through mode remsh remoteserverhostname find /tmp/a1 | cpio -pd /tmp current </tmp/tmp/a1/b1/y1> newer current </tmp/tmp/a1/b1/z1> newer current </tmp/tmp/a1/b2/l2smc> newer "/tmp/a1/b3": No such file or directory Cannot stat </tmp/a1/b3>. 0 blocks so when i try to cpio -pd option , i am expecting it to create directories for me but it does not i was using rcp but its not preserving symbolic links :( what can i do ? hp-ux

    Read the article

  • Crossdomain file edit

    - by Misiur
    Hi there. I need to know, where from is my script used (it's for sale, and i don't want any thiefs). I want to write on my server in file, IP of user, domain where from script has been runned, date, etc. I've tried fopen, fwrite, but is_file_writable returned that it isn't. File CHmods are 777, it parent catalog has too 777 chmods. Now i'm trying something like that: <?php $file = 'http://www.misiur.com/security/seal.txt'; $data = date("Y-m-d H:i:s"); $ip = $_SERVER['REMOTE_ADDR']; $svr = $_SERVER['SERVER_NAME']; $str = "[$data] Loaded by $ip at $svr\r\n"; $current = file_get_contents($file); $current .= $str; file_put_contents($file, $current); ?> However - nothing happens. What i've got to do?

    Read the article

  • Get list of Unique many-to-many records from a queryset

    - by rsp
    My models: class Order(models.Model): ordered_by = models.ForeignKey(User) reasons = models.ManyToManyField(Reason) class Reason(models.Model): description = models.CharField() Basically a user creates an order and gives reasons for that order. ie, john has two orders (one for pencils because he is out AND because he doesn't like his current stock. a second order for pens because he is out). I want to print a list out of all reasons a user has placed his orders. So under john, it should print "he is out", "he doesn't like his current stock"; those two lines only. If I simply select all of john's orders, iterate through them and print out their "reasons" it'll print "he is out", "he doesn't like his current stock" and then "he is out" again. I don't want these duplicate values. How do I select a list of his reasons for ALL his orders so that the list has all unique rows?

    Read the article

  • remote cpio copy

    - by soField
    remsh remoteserverhostname -l remoteusername find /tmp/a1/ | cpio -o > /tmp/paketr.cpio rcp remoteserverhostname:/tmp/paketr.cpio /tmp/aaa cpio -idmv < /tmp/paketr.cpio i'am trying to get and create directory structure from remote server to local server i can do this with following command list but i wonder if i can do this with just one command by running cpio with pass-through mode remsh remoteserverhostname find /tmp/a1 | cpio -pd /tmp current </tmp/tmp/a1/b1/y1> newer current </tmp/tmp/a1/b1/z1> newer current </tmp/tmp/a1/b2/l2smc> newer "/tmp/a1/b3": No such file or directory Cannot stat </tmp/a1/b3>. 0 blocks so when i try to cpio -pd option , i am expecting it to create directories for me but it does not what can i do ?

    Read the article

  • Replace LinkedList element value through LinkedList.Enumerator

    - by Yan Cheng CHEOK
    I realize there are no way for me to replace value through LinkedList.Enumerator. For instead, I try to port the below Java code to C# // Java ListIterator<Double> itr1 = linkedList1.listIterator(); ListIterator<Double> itr2 = linkedList2.listIterator(); while(itr1.hasNext() && itr2.hasNext()){ Double d = itr1.next() + itr2.next(); itr1.set(d); } // C# LinkedList<Double>.Enumerator itr1 = linkedList1.GetEnumerator(); LinkedList<Double>.Enumerator itr2 = linkedList2.GetEnumerator(); while(itr1.MoveNext() && itr2.MoveNext()){ Double d = itr1.Current + itr2.Current; // Opps. Compilation error! itr1.Current = d; } Any other technique I can use?

    Read the article

  • emacs: force ido-mode to forget history...

    - by Stephen
    Hi, I wonder if I can keep ido from not remembering my history and only show completions for files that are in the current directory when I am searching for a file. I understand that this history feature is useful at times, but I often end up editing the incorrect file because I think I am editing file called 'abc.txt' in the current directory but in fact I am editing the file by the same name in another one that I previously visited (often happens when there is not an 'abc.txt' in the current directory, as I mistakenly assume). From reading the ido.el file I thought to set in my .emacs file (also evaluated these expressions in running emacs instance): (custom-set-variables '(ido-enable-last-directory-history nil) '(ido-record-commands nil) ) and deleted a file called .ido.last in ~/, but still it remembers some previous files I've visited before making these changes. How can I purge my previous history, and I am not entirely sure what the difference between the two variables above are but seems to have done the trick to keep ido from remembering files I visit in the future? Thanks for your help!

    Read the article

  • Problems with VBScript - RegRead when running as a service

    - by Brandon
    I am working on a script that runs under a custom installation utility, which is running as a service. To get the current user name the script executes this command: str_Acct_Name_Val = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon User Name" str_Acct_Name = RegRead(str_Acct_Name_Val) When I run the script from the command prompt, it can read that value just fine (under an administrator account). When the value is attempted to be read with service/local system privileges, the read fails. What is the problem here? EDIT: Some additional information. When running as a service calling the current user name returns "SYSTEM" and my guess is that HKCU doesn't "exist" under the view of the SYSTEM, since there is technically no current user. There is a user logged in at the time, but not in the scope of the running script. Maybe there is somewhere in HKLM I could find the currently logged on user?

    Read the article

  • Java printf using variable field size?

    - by paxdiablo
    I'm just trying to convert some C code over to Java and I'm having a little trouble with String.printf. In C, to get a specific width based on a variable, I can use: printf("Current index = %*d\n", sz, index); and it will format the integer to be a specific size based on sz. Trying: System.out.println(String.format("Current index = %*d\n", sz, index)); results in an error since it doesn't like the *. I currently have the following kludge: System.out.println(String.format("Current index = %" + sz + "d\n", index)); but I'm hoping there's a slightly better way, yes?

    Read the article

  • How do I set the next available custom color in the ColorDialog?

    - by Hannah
    I'm currently coding in VB.net. A user places the cursor in a table cell and clicks on "Table Background Color" to edit the current background colour. Currently I have been able to detect the current colour (for instance a light blue) and set that colour in the ColorDialog (Colour swatches are correct and RGB values are correct). What I would like to do is enable the user to click on the "Add to Custom Colors" to save the colour. Problem is, it sets the first square in the custom colours area (which happens to already be filled in with another custom colour), rather than finding the next square that is white and set it there instead. Is this possible? If the user selects a new custom colour square when they first load the ColorDialog, the current colour (light blue) disappears and the colour swatches and RGB values are set as white. Thanks

    Read the article

  • Request is not available in this context

    - by Vishal Seth
    I'm running IIS 7 Integrated mode and I'm getting Request is not available in this context when I try to access it in a Log4Net related function that is called from Application_Start. This is the line of code I've if (HttpContext.Current != null && HttpContext.Current.Request != null) and an exception is being thrown for second comparison. What else can I check other than checking HttpContext.Current.Request for null?? A similar question is posted @ http://stackoverflow.com/questions/2056398/request-is-not-available-in-this-context-exception-when-runnig-mvc-on-iis7-5 but no relevant answer there either.

    Read the article

  • How to refresh parent page using javascript / asp.net in mozilla firefox browser

    - by Rajesh Rolen- DotNet Developer
    window.opener.location.reload(); is working fine with IE but not refreshing parent page in mozilla firefox browser.. please tell me how to refresh parent page in cross browser. i have got this function : Shared Sub CloseMyWindow() Dim tmpStr As String = "" tmpStr += "window.open('','_parent','');window.close();" tmpStr += "window.opener.location.reload();" 'Dim currentPage As Page = TryCast(HttpContext.Current.Handler, Page) 'currentPage.ClientScript.RegisterStartupScript(GetType(me), "refresh", tmpStr, True) HttpContext.Current.Response.Write("<script language='javascript'>" + tmpStr + "</script>") HttpContext.Current.Response.End() End Sub

    Read the article

  • Best Design for a Facebook clone on GAE Java

    - by charming30
    My current App is written in Python on GAE which can do Contacts management, Genealogy, Social Networking, Photo sharing, Telecom Integration (SMS, iVRS, URL Billing), CRON and performs business logic operations for our Mobile Apps. Current Architecture indlues python, django, jquery, memcache and few telecom APIs. Now, It feels that an SOA Architecture on GAE using Java would be really ideal and scalable for this kind of App where we want to build new features like widgets that users can turn on or off and third party developers can also develop and deploy features. Please correct me or improve the following design decision: UI (Current plan is GWT) Sessions, Security and ACL (Spring MVC 2.x) Reusable Business Logic components (?) Implementation of Web Services (?) Your advice would really help.

    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

  • Separation of concerns and authentication

    - by Tom Gilder
    I'm trying to be a Good Developer and separate my concerns out. I've got an ASP.NET MVC project with all my web code, and a DAL project with all the model code. Sometimes code in the DAL needs to check if the current user is authorized to perform some actions, by checking something like CurrentUser.IsAdmin. For the web site, the current is derived from the Windows username (from HttpContext.Current.User.Identity), but this is clearly a web concern and shouldn't be coupled to the DAL. What's the best pattern to loosely couple the authentication? Should the DAL be asking the MVC code for a username, or the MVC be telling the DAL? Are there advantages or disadvantages to one or the other? Thank you!

    Read the article

  • I need unusual ordering mysql results

    - by Patrick
    Im trying to order results ASCENDING from the current date this is what im using now; SELECT * FROM friends JOIN bdays ON bdays.user = friends.friendname WHERE username = $userid ORDER BY DATE_FORMAT(date, '%m %d') any ideas? example ordering by date now, sorts the birthdays starting at january what i need, is instead of starting the list at january, is starting it from the current date. So, instead of; January February March April May June July August September November December It will order them like this; April (current month/day) May June July August September November December January February March April (all the way up to yesterday)

    Read the article

  • replace a text string

    - by shantanuo
    I want to replace the date found at the end of the "datadir" line with the current date. For e.g. my my.cnf file looks like this... # head /etc/my.cnf [mysqld] #mount -t tmpfs -o size=102m tmpfs /mnt #datadir=/mnt read-only datadir=/mysqlApr5 #datadir=/mysqlApr2 #datadir=/mysqlMar16 #datadir=/mysqlFeb25a Most of the lines are commented. I need to find the datadir line that is not commented and then replace the /mysqlApr4 with /mysqlApr20 datadir=/mysqlApr20 If it is possible I will like to comment the older datadir path. #datadir=/mysqlApr5 I can output the current date as: date '+%b%d' But I want to concat it with the word "/mysql" and replace or comment the current datadir line.

    Read the article

  • jqgrid - edit form field combobox not defaulting to selected row value after first edit

    - by ooo
    i am using jqgrid with asp.net-mvc. I have an edit form (using jqmodal) which works great but for some reason one combobox field doesn't default to the current selected row after the first time i bring up the edit form. the weird thing is that i have many other comboboxes which work fine every time and i don't see any real difference. here is an example of the field that doesn't work: { name: "TechOwner", index: "TechOwner", width: 70, editable: true, edittype: "select", editoptions: { dataUrl: "/Person/GetSelectData" }, editrules: { required: true} }, and here is a field that works fine: { name: "FundingType", index: "FundingType", align: "left", width: 25, editable: true, edittype: "select", editoptions: { dataUrl: "/Project/FundingGetSelectData" }, editrules: { required: true} }, the dropdown is getting populated with all options (including the current selected row option) but its just defaulting to the top item) instead of one that matches the current row. is there anything to look out for here that may cause this behavior?

    Read the article

  • How to set the path to "context path" for uploaded files using Apache Common fileupload?

    - by BugKiller
    Hi, I'm using Apache common fileupload library with Netbeans 6.8 + Glassfish.I'm trying to change the current upload path to be in the current context path of the servlet , something like this: WEB-INF/upload so I wrote : File uploadedFile = new File("WEB-INF/upload/"+fileName); session.setAttribute("path",uploadedFile.getAbsolutePath()); item.write(uploadedFile); but I notice that the library save the uploaded files into glassfish folder , here what I get when I print the absolute path of the uploaded file : C:\Program Files\sges-v3\glassfish\domains\domain1\WEB-INF\upload\xx.rar My Question : How can I force the common fileupload to save the uploaded file in a path relative to the current servlet path , so I don't need to specify the whole path ? is this possible ?

    Read the article

  • How is it possible to get the forms mouseposition when clicking inside a control?

    - by ikky
    Hi. I have a panel and have added a PictureBox to it. I have added mouse_click listeners to both the panel and the picturebox. When they are clicked i create a messagebox which tells me the mouse position. Problem: When i click the panel, i get the mouse position i want. When i click the pictureBox, i get the current position in that picturebox. What i want: I want both of the controls to get the current mouseposition on the form. I can also go with getting the current mouseposition of the panel, since it is overlaying the form. Does anybody know how i can do this? I've googled around for this, but can't seem to find anything about it. Thank you in advance.

    Read the article

  • Polymorphic Behavior in VB6

    - by Tom Tresansky
    I recently noticed the CallByName keyword in VB6. Since this takes a object, procedure name, "call type" and arguments array, can this be used to "fake" some types of polymorphic behavior? I can make 2 classes, class A and B, each with the same method Foo, and do: Dim list As New Collection Dim instanceA As New ClassA Dim instanceB As New ClassB Dim current As Object Call list.Add(instanceA) Call list.Add(instanceB) For Each current in list Call CallByName(current, "methodName", vbMethod) Next Anyone done this before? Problems? Horrible idea or genius idea? Implications? Unintended consequences?

    Read the article

  • Date Comparision using Java

    - by Lakshman
    To Date (User Input - format - MM/dd/YYYY) Current Date. I need to compare the current date with To Date. Note: currenet date i get using Date currDt = new Date(). I have to display a report only when the toDate is equal to or more than currentDate. How to compare both the date. [ToDate is a String type i always get in mm/dd/yyyy] Current Date is Date currDt = new Date(). How to compare both the dates. need snippet.

    Read the article

< Previous Page | 73 74 75 76 77 78 79 80 81 82 83 84  | Next Page >