Search Results

Search found 513 results on 21 pages for 'arr'.

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

  • URL Parts available to URL Rewrite Rules

    - by OWScott
    URL Rewrite is a powerful URL rewriting tool available for IIS7 and newer.  Your rewriting options are almost unlimited, giving you the ability to optimize URLs for search engine optimization (SEO), support multiple domain names on a single site, hiding complex paths and much more. URL Rewrite allows you to use any Server Variable as conditions, and with URL Rewrite 2.0, you can also update them on the fly.  To see all variables available to your site, see this post. An understanding of the parts of a complete URL are essential to working with URL Rewrite, so I’ll include the basics here.  Ruslan Yakushev’s configuration reference was my authoritative source for this. Take this URL for example: The URL is http://www.bing.com/search?q=IIS+url+rewrite The parts of the URL are: http(s)://<host>:<port>/<path>?<querystring> Part Example Server Variable http(s) http SERVER_PORT_SECURE or HTTPS = on/off <host> www.bing.com HTTP_HOST <port> Default is 80 SERVER_PORT <path> search The rule pattern in URL Rewrite <path> /search PATH_INFO <querystring> q=IIS+url+rewrite QUERY_STRING entire URL path with querystring /search?q=IIS+url+rewrite REQUEST_URI It’s important to note that /, : and ? aren’t included in some of the server variables. Understanding which slashes are included is important to creating successful rules.

    Read the article

  • URL Rewrite – Protocol (http/https) in the Action

    - by OWScott
    IIS URL Rewrite supports server variables for pretty much every part of the URL and http header. However, there is one commonly used server variable that isn’t readily available.  That’s the protocol—HTTP or HTTPS. You can easily check if a page request uses HTTP or HTTPS, but that only works in the conditions part of the rule.  There isn’t a variable available to dynamically set the protocol in the action part of the rule.  What I wish is that there would be a variable like {HTTP_PROTOCOL} which would have a value of ‘HTTP’ or ‘HTTPS’.  There is a server variable called {HTTPS}, but the values of ‘on’ and ‘off’ aren’t practical in the action.  You can also use {SERVER_PORT} or {SERVER_PORT_SECURE}, but again, they aren’t useful in the action. Let me illustrate.  The following rule will redirect traffic for http(s)://localtest.me/ to http://www.localtest.me/. <rule name="Redirect to www"> <match url="(.*)" /> <conditions> <add input="{HTTP_HOST}" pattern="^localtest\.me$" /> </conditions> <action type="Redirect" url="http://www.localtest.me/{R:1}" /> </rule> The problem is that it forces the request to HTTP even if the original request was for HTTPS. Interestingly enough, I planned to blog about this topic this week when I noticed in my twitter feed yesterday that Jeff Graves, a former colleague of mine, just wrote an excellent blog post about this very topic.  He beat me to the punch by just a couple days.  However, I figured I would still write my blog post on this topic.  While his solution is a excellent one, I personally handle this another way most of the time.  Plus, it’s a commonly asked question that isn’t documented well enough on the web yet, so having another article on the web won’t hurt. I can think of four different ways to handle this, and depending on your situation you may lean towards any of the four.  Don’t let the choices overwhelm you though.  Let’s keep it simple, Option 1 is what I use most of the time, Option 2 is what Jeff proposed and is the safest option, and Option 3 and Option 4 need only be considered if you have a more unique situation.  All four options will work for most situations. Option 1 – CACHE_URL, single rule There is a server variable that has the protocol in it; {CACHE_URL}.  This server variable contains the entire URL string (e.g. http://www.localtest.me:80/info.aspx?id=5)  All we need to do is extract the HTTP or HTTPS and we’ll be set. This tends to be my preferred way to handle this situation. Indeed, Jeff did briefly mention this in his blog post: … you could use a condition on the CACHE_URL variable and a back reference in the rewritten URL. The problem there is that you then need to match all of the conditions which could be a problem if your rule depends on a logical “or” match for conditions. Thus the problem.  If you have multiple conditions set to “Match Any” rather than “Match All” then this option won’t work.  However, I find that 95% of all rules that I write use “Match All” and therefore, being the lazy administrator that I am I like this simple solution that only requires adding a single condition to a rule.  The caveat is that if you use “Match Any” then you must consider one of the next two options. Enough with the preamble.  Here’s how it works.  Add a condition that checks for {CACHE_URL} with a pattern of “^(.+)://” like so: How you have a back-reference to the part before the ://, which is our treasured HTTP or HTTPS.  In URL Rewrite 2.0 or greater you can check the “Track capture groups across conditions”, make that condition the first condition, and you have yourself a back-reference of {C:1}. The “Redirect to www” example with support for maintaining the protocol, will become: <rule name="Redirect to www" stopProcessing="true"> <match url="(.*)" /> <conditions trackAllCaptures="true"> <add input="{CACHE_URL}" pattern="^(.+)://" /> <add input="{HTTP_HOST}" pattern="^localtest\.me$" /> </conditions> <action type="Redirect" url="{C:1}://www.localtest.me/{R:1}" /> </rule> It’s not as easy as it would be if Microsoft gave us a built-in {HTTP_PROTOCOL} variable, but it’s pretty close. I also like this option since I often create rule examples for other people and this type of rule is portable since it’s self-contained within a single rule. Option 2 – Using a Rewrite Map For a safer rule that works for both “Match Any” and “Match All” situations, you can use the Rewrite Map solution that Jeff proposed.  It’s a perfectly good solution with the only drawback being the ever so slight extra effort to set it up since you need to create a rewrite map before you create the rule.  In other words, if you choose to use this as your sole method of handling the protocol, you’ll be safe. After you create a Rewrite Map called MapProtocol, you can use “{MapProtocol:{HTTPS}}” for the protocol within any rule action.  Following is an example using a Rewrite Map. <rewrite> <rules> <rule name="Redirect to www" stopProcessing="true"> <match url="(.*)" /> <conditions trackAllCaptures="false"> <add input="{HTTP_HOST}" pattern="^localtest\.me$" /> </conditions> <action type="Redirect" url="{MapProtocol:{HTTPS}}://www.localtest.me/{R:1}" /> </rule> </rules> <rewriteMaps> <rewriteMap name="MapProtocol"> <add key="on" value="https" /> <add key="off" value="http" /> </rewriteMap> </rewriteMaps> </rewrite> Option 3 – CACHE_URL, Multi-rule If you have many rules that will use the protocol, you can create your own server variable which can be used in subsequent rules. This option is no easier to set up than Option 2 above, but you can use it if you prefer the easier to remember syntax of {HTTP_PROTOCOL} vs. {MapProtocol:{HTTPS}}. The potential issue with this rule is that if you don’t have access to the server level (e.g. in a shared environment) then you cannot set server variables without permission. First, create a rule and place it at the top of the set of rules.  You can create this at the server, site or subfolder level.  However, if you create it at the site or subfolder level then the HTTP_PROTOCOL server variable needs to be approved at the server level.  This can be achieved in IIS Manager by navigating to URL Rewrite at the server level, clicking on “View Server Variables” from the Actions pane, and added HTTP_PROTOCOL. If you create the rule at the server level then this step is not necessary.  Following is an example of the first rule to create the HTTP_PROTOCOL and then a rule that uses it.  The Create HTTP_PROTOCOL rule only needs to be created once on the server. <rule name="Create HTTP_PROTOCOL"> <match url=".*" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{CACHE_URL}" pattern="^(.+)://" /> </conditions> <serverVariables> <set name="HTTP_PROTOCOL" value="{C:1}" /> </serverVariables> <action type="None" /> </rule>   <rule name="Redirect to www" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{HTTP_HOST}" pattern="^localtest\.me$" /> </conditions> <action type="Redirect" url="{HTTP_PROTOCOL}://www.localtest.me/{R:1}" /> </rule> Option 4 – Multi-rule Just to be complete I’ll include an example of how to achieve the same thing with multiple rules. I don’t see any reason to use it over the previous examples, but I’ll include an example anyway.  Note that it will only work with the “Match All” setting for the conditions. <rule name="Redirect to www - http" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{HTTP_HOST}" pattern="^localtest\.me$" /> <add input="{HTTPS}" pattern="off" /> </conditions> <action type="Redirect" url="http://www.localtest.me/{R:1}" /> </rule> <rule name="Redirect to www - https" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{HTTP_HOST}" pattern="^localtest\.me$" /> <add input="{HTTPS}" pattern="on" /> </conditions> <action type="Redirect" url="https://www.localtest.me/{R:1}" /> </rule> Conclusion Above are four working examples of methods to call the protocol (HTTP or HTTPS) from the action of a URL Rewrite rule.  You can use whichever method you most prefer.  I’ve listed them in the order that I favor them, although I could see some people preferring Option 2 as their first choice.  In any of the cases, hopefully you can use this as a reference for when you need to use the protocol in the rule’s action when writing your URL Rewrite rules. Further information: Viewing all Server Variable for a site. URL Parts available to URL Rewrite Rules Further URL Rewrite articles

    Read the article

  • Using IIS Application Request Routing (ARR) for ASP.NET MVC

    - by Malcolm Frexner
    I use a simple ASP.NET MVC web (the template you use when you create a new site) and the web works as expected in my live environment. I now try to use IIS Application Request Routing version 2. I have a rule that send all reuqests to a different server that match a rule. The settings are a bit like this: http://blogs.iis.net/wonyoo/archive/2008/07/09/application-request-routing-arr-as-a-reverse-proxy.aspx My rule is just a bit different it is /shop(.*). Only requests that contain shop are send to a different server. I have to use rewrite, not redirect (The same as in the Picture) This works as long as the web the original requests go to is no ASP.NET MVC web. I tried to use a plain htm file in the webfolder and it worked. If put a compiled ASP.NET application into the webfolder it worked. But as soon as I put an ASP.NET MVC web into the folder, request arr served by this application. My understanding is that the ARR should kick in before the web application gets the chance to handle the request. Did anybody use ARR sucessfully as a reverse proxy for a ASP.NET MVC web? EDIT Here is the resulting web config when the rewrite roule is entered. With this rule I get a 404 that indicates that the rule is not used. <?xml version="1.0" encoding="UTF-8"?> <configuration> <configSections> <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" /> <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> </sectionGroup> </sectionGroup> </sectionGroup> </configSections> <appSettings /> <connectionStrings> <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <!-- Set compilation debug="true" to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development. --> <compilation debug="false"> <assemblies> <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> </assemblies> </compilation> <!-- The <authentication> section enables configuration of the security authentication mode used by ASP.NET to identify an incoming user. --> <authentication mode="Forms"> <forms loginUrl="~/Account/LogOn" timeout="2880" /> </authentication> <membership> <providers> <clear /> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/" /> </providers> </membership> <profile> <providers> <clear /> <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ApplicationServices" applicationName="/" /> </providers> </profile> <roleManager enabled="false"> <providers> <clear /> <add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> </roleManager> <!-- The <customErrors> section enables configuration of what to do if/when an unhandled error occurs during the execution of a request. Specifically, it enables developers to configure html error pages to be displayed in place of a error stack trace. <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> <error statusCode="403" redirect="NoAccess.htm" /> <error statusCode="404" redirect="FileNotFound.htm" /> </customErrors> --> <pages> <controls> <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </controls> <namespaces> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> <add namespace="System.Linq" /> <add namespace="System.Collections.Generic" /> </namespaces> </pages> <httpHandlers> <remove verb="*" path="*.asmx" /> <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" /> <add verb="*" path="*.mvc" validate="false" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </httpHandlers> <httpModules> <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </httpModules> </system.web> <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <providerOption name="CompilerVersion" value="v3.5" /> <providerOption name="WarnAsError" value="false" /> </compiler> <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <providerOption name="CompilerVersion" value="v3.5" /> <providerOption name="OptionInfer" value="true" /> <providerOption name="WarnAsError" value="false" /> </compiler> </compilers> </system.codedom> <system.web.extensions /> <!-- The system.webServer section is required for running ASP.NET AJAX under Internet Information Services 7.0. It is not necessary for previous version of IIS. --> <system.webServer> <rewrite> <rules> <rule name="shop" stopProcessing="true"> <match url="^shop/([_0-9a-z-.]+)" /> <action type="Rewrite" url="article.aspx?title={R:1}" logRewrittenUrl="true" /> </rule> </rules> </rewrite> <validation validateIntegratedModeConfiguration="false" /> <modules runAllManagedModulesForAllRequests="true"> <remove name="ScriptModule" /> <remove name="UrlRoutingModule" /> <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </modules> <handlers> <remove name="WebServiceHandlerFactory-Integrated" /> <remove name="ScriptHandlerFactory" /> <remove name="ScriptHandlerFactoryAppServices" /> <remove name="ScriptResource" /> <remove name="MvcHttpHandler" /> <remove name="UrlRoutingHandler" /> <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </handlers> </system.webServer> </configuration>

    Read the article

  • Removing elements from heap

    - by user193138
    I made a heap. I am curious if there's something subtley wrong with my remove function: int Heap::remove() { if (n == 0) exit(1); int temp = arr[0]; arr[0] = arr[--n]; heapDown(0); arr[n] = 0; return temp; } void Heap::heapDown(int i) { int l = left(i); int r = right(i); // comparing parent to left/right child // each has an inner if to handle if the first swap causes a second swap // ie 1 -> 3 -> 5 // 3 5 1 5 1 3 if (l < n && arr[i] < arr[l]) { swap(arr[i], arr[l]); heapDown(l); if (r < n && arr[i] < arr[r]) { swap(arr[i], arr[r]); heapDown(r); } } else if (r < n && arr[i] < arr[r]) { swap(arr[i], arr[r]); heapDown(r); if (l < n && arr[i] < arr[l]) { swap(arr[i], arr[l]); heapDown(l); } } } Here's my output i1i2i3i4i5i6i7 p Active heap: 7 4 6 1 3 2 5 r Removed 7 r Removed 6 p Active heap: 5 3 4 1 2 Here's my teacher's sample output: p Active heap : 7 4 6 1 3 2 5 r Removed 7 r Removed 6 p Active heap : 5 4 2 1 3 s Heapsorted : 1 2 3 4 5 While our outputs are completely different, I do seem to hold maxheap principle of having everything left oriented and for all nodes parent child(in every case I tried). I try to do algs like this from scratch, so maybe I'm just doing something really weird and wrong (I would only consider it "wrong" if it's O(lg n), as removes are intended to be for heaps). Is there anything in particular "wrong" about my remove? Thanks, http://ideone.com/PPh4eQ

    Read the article

  • perl array of hashes sorting

    - by srk
    use strict; my @arr; $arr[0][0]{5} = 16; $arr[0][1]{6} = 11; $arr[0][2]{7} = 25; $arr[0][3]{8} = 31; $arr[0][4]{9} = 16; $arr[0][5]{10} = 17; sort the array based on hash values so this should change to $arr[0][0]{6} = 11; $arr[0][1]{9} = 16; $arr[0][2]{5} = 16; $arr[0][3]{10} = 17; $arr[0][4]{7} = 25; $arr[0][5]{8} = 31; first sort on values in the hash.. when the values are same reverse sort based on keys... Please tell me how to do this.. Thank you

    Read the article

  • How to find ordinal position of an element in XML using VBScript & XPATH

    - by chazzuka
    I have an XML like this <response> <doc> <arr name="URL"><str>string</str></arr> <arr name="ID"><int>1</int></arr> </doc> <doc> <arr name="URL"><str>string</str></arr> <arr name="ID"><int>2</int></arr> </doc> <doc> <arr name="URL"><str>string</str></arr> <arr name="ID"><int>3</int></arr> </doc> </response> How to get the ordinal position of doc element which has element arr(1)/int text = 2 I am Using Classic ASP thanks

    Read the article

  • Adding select menu default value via JS?

    - by purpler
    Hi, i'm developing a meta search engine website, Soogle and i've used JS to populate select menu.. Now, after the page is loaded none of engines is loaded by default, user needs to select it on his own or [TAB] to it.. Is there a possibility to preselect one value from the menu via JS after the page loads? This is the code: Javascript: // SEARCH FORM INIT function addOptions(){ var sel=document.searchForm.whichEngine;for(var i=0;i<arr.length;i++){ sel.options[i]=new Option(arr[i][0],i)}} function startSearch(){ searchString=document.searchForm.searchText.value;if(searchString!=""){ var searchEngine=document.searchForm.whichEngine.selectedIndex; var finalSearchString=arr[searchEngine][1]+searchString;location.href=finalSearchString}return false} function checkKey(e){ var character=(e.which)?e.which:event.keyCode;if(character=='13'){ return startSearch()}} // SEARCH ENGINES INIT var arr = new Array(); arr[arr.length] = new Array("Web", "http://www.google.com/search?q="); arr[arr.length] = new Array("Images", "http://images.google.com/images?q="); arr[arr.length] = new Array("Knoweledge","http://en.wikipedia.org/wiki/Special:Search?search="); arr[arr.length] = new Array("Videos","http://www.youtube.com/results?search_query="); arr[arr.length] = new Array("Movies", "http://www.imdb.com/find?q="); arr[arr.length] = new Array("Torrents", "http://thepiratebay.org/search/"); HTML: <body onload="addOptions();document.forms.searchForm.searchText.focus()"> <div id="wrapper"> <div id="logo"></div> <form name="searchForm" method="POST" action="javascript:void(0)"> <input name="searchText" type="text" onkeypress="checkKey(event);"/> <span id="color"></span> <select tabindex="1" name="whichEngine" selected="Web"></select> <br /> <input tabindex="2" type="button" onClick="return startSearch()" value="Search"/> </form> </div> </body>

    Read the article

  • Why i get Two value for ArrAffinity in my Cookie with Application Request Routing web servers setup

    - by Cédric Boivin
    Hello, I got a problem with ARR and my webfarm. I got a application develop, with a login page, when i log into my web application, i always log out. So I download fiddler to valid the affinity with my server and i see i got two value of key ArrAffinity in my cookie. Somme page got two value : ARRAffinity=2ea1e079a7e09ee9844bb1f5eca66f4f94432d3e832c073b80e0091fda6a54d4 ARRAffinity=d000ece875153770e561ea2d34d5ce85968d56e7a02104e726a25d445de25eed Other one got only have one ARRAffinity=d000ece875153770e561ea2d34d5ce85968d56e7a02104e726a25d445de25eed With this problem, i think my http request, is send to radom iis server on my farm, so the impact is i am disconnect. Anny idea ?

    Read the article

  • embedded tomcat 7 behind iis 7.5 proxy ssl problems

    - by user1058410
    I'm using embedded tomcat 7 behind a iis 7.5 proxy server, with requests being forwarded to tomcat with arr. Everything works fine unless iis is set to require ssl. Then things like links that are generated dynamically in .jsp files on tomcat don't work right. For example if a link is supposed to point to _https://somewhere.com:443 it will be wrote as _http://somewhere.com:8080 (8080 is the port tomcat is running on). The problem seems to come from when tomcat looks at itself to build out the url it sees correctly that it is running on _http://somewhere.com:8080, but i need it to think otherwise. Does anybody know how to accomplish this without using ssl between iis and tomcat? Sorry for the underscores in front of the imaginary urls.

    Read the article

  • How failover should work in IIS cluster with Application Request Routing?

    - by username
    I have set up several servers with IIS and connected them to the load balancer - server with installed IIS Application Request Routing. I have created a server farm and added two servers. Then I stopped IIS on the first server and tried to open my web site. It returned me an error: 502 - Web server received an invalid response while acting as a gateway or proxy server. But if instead of stopping IIS I shut down the first server, I'm getting a response from the next server which is online. The question is, what the expected behaviour should be for failover with ARR, should it switch me to the next server if IIS is stopped and server is online?

    Read the article

  • IIS7 and ARR as reverse proxy for Subversion

    - by Paul Stovell
    I am using IIS7 and the Application Request Routing extension to act as a reverse proxy to Subversion running on Apache. The proxy works fine and I am able to explore the server, and even perform a "check out". However, I cannot browse to files that would normally be forbidden by ASP.NET - for example, .cs, .csproj, and so on. Files ASP.NET wouldn't be concerned with - such as .txt - are fine. I tried to edit the global web.config to remove the Forbidden handler mapping for these files, but it did not seem to make a difference. Is there any way to allow the URL rewriting module in IIS7 to work, while allowing all file extensions to be rendered?

    Read the article

  • Sorting an array of strings in reverse alphabetical order in Java

    - by Quacky
    I've been tasked with turning this code into a reverse sort, but for the life of me cannot figure out how to do it. These are my sort, findlargest and swap methods. I have a feeling I am missing something glaringly obvious here, any help would be really appreciated. public static void sort(String[] arr) { for (int pass = 1; pass < arr.length; pass++) { int largestPos = findLargest(arr, arr.length - pass); if (largestPos != arr.length - pass) { swap(arr, largestPos, arr.length - pass); } } } public static int findLargest(String[] arr, int num) { int largestPos = 0; for (int i = 1; i <= num; i++) { if (arr[i].compareToIgnoreCase(arr[largestPos]) > 0) { largestPos = i; } } return largestPos; } public static void swap(String[] arr, int first, int second) { String temp = arr[first]; arr[first] = arr[second]; arr[second] = temp; } }

    Read the article

  • numberOfSectionsInTable isn't called when [arr count] is returned

    - by user315471
    When I try returning the count of my newsItems array it breaks my application. I used NSLog to find out what the value of the newsItems count was when I returned 1. Here is from NSLog 2010-04-13 07:48:40.656 RSS Feed[453:207] Values of num items 31 2010-04-13 07:48:40.656 RSS Feed[453:207] Number of items 31 Does anyone know why returning [newsItems count] would cause my application to break? - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { NSLog(@"Values of num items %d",[newsItems count]); NSInteger *length = (NSInteger *)[newsItems count]; NSLog(@"Number of items %d",length); return 1; //return [newsItems count]; //This keeps breaking it for some reason }

    Read the article

  • Sorting arrays in java

    - by user360706
    Write a static method in Java : public static void sortByFour (int[] arr) That receives as a paramater an array full of non-negative numbers (zero or positive) and sorts the array in the following way : In the beginning of the array all the numbers that devide by four without a remainder will appear. After them all the numbers in the array that devide by 4 with a remainder of 1 will appear. After them all the numbers in the array that devide by 4 with a remainder of 2 will appear. In the end of the array all the rest numbers (those who divide by 4 with the remainder 3) will appear. (The order of the numbers in each group doesn't matter) The method must be the most efficient it can. This is what I wrote but unfortunately it doesn't work well... :( public static void swap( int[] arr, int left, int right ) { int temp = arr[left]; arr[left] = arr[right]; arr[right] = temp; } public static void sortByFour( int[] arr ) { int left = 0; int right = ( arr.length - 1 ); int mid = ( arr.length / 2 ); while ( left < right ) { if ( ( arr[left] % 4 ) > ( arr[right] % 4 ) ) { swap( arr, left, right ); right--; } if ( ( arr[left] % 4 ) == ( arr[right] % 4 ) ) left++; else left++; } } Can someone please help me by fixing my code so that it will work well or rewriting it?

    Read the article

  • solving problems recursively in C

    - by Harry86
    Our professor gave us the following assignment: A "correct" series is one inwhich the sum of its members equals to the index of its first member. The program is supposed to find the length of the LONGEST "correct" series within a series of n numbers. for example: if the input series would be arr[4]={1, 1, 0, 0} the output (longest "correct" series) would be 3. arr[0]=1. 0!=1 therefore the longest series here is 0. arr[1]=1,and 1=1. but the follwing members also sum up to 1 as shown below: 1=arr[1]+arr[2]+arr[3] = 1+ 0 + 0, therefore the longest series here is 3. the output in this example is 3. That's what I got so far: int solve(int arr[], int index, int length,int sum_so_far) { int maxwith,maxwithout; if(index==length) return 0; maxwith = 1+ solve(arr,index+1,length,sum_so_far+arr[index]); maxwithout = solve(arr,index+1,length,arr[index+1]); if(sum_so_far+arr[index]==index) if(maxwith>maxwithout) return maxwith; return maxwithout; return 0; } int longestIndex(int arr[], int index,int length) { return solve(arr,0,length,0); } What am I doing wrong here? Thanks a lot for your time... Harry

    Read the article

  • Routing a url to fetch content from another site

    - by Abhishek
    Environment: IIS 7. I have a default site www.domain.com and its folder is C:Inetpub/wwwroot/domain There is subdomain www.subdomain.domain.com and its folder is C:Inetpub/wwwroot/domain/subdomain. Now I have setup a new website at an external server. I cannot put the content on the above server due to some reasons. I need the URL www.subdomain.domain.com/blog fetch content from this external server while the URL should remain the same. How could this be achieved in IIS 7?

    Read the article

  • JQuery $.unique() issue ie

    - by vanzylv
    Hi Guys var arr = new Array(); arr[0] = 'Departmental News' arr[1] = 'Departmental News' arr[2] = 'Another Cat' arr[3] = 'Another Cat' arr[4] = 'Departmental News' alert(arr) alert($.unique(arr)) In IE I get duplicates. In any other browser only the unique ones Any Ideas?

    Read the article

  • Big-Oh running time of code in Java (are my answers accurate

    - by Terry Frederick
    the Method hasTwoTrueValues returns true if at least two values in an array of booleans are true. Provide the Big-Oh running time for all three implementations proposed. // Version 1 public boolean has TwoTrueValues( boolean [ ] arr ) { int count = 0; for( int i = 0; i < arr. length; i++ ) if( arr[ i ] ) count++; return count >= 2; } // Version 2 public boolean hasTwoTrueValues( boolean [ ] arr ) { for( int i = 0; i < arr.length; i++ ) for( int j = i + 1; j < arr.length; j++ ) if( arr[ i ] && arr[ j ] ) return true; } // Version 3 public boolean hasTwoTrueValues( boolean [ ] arr ) { for( int i = 0; i < arr.length; i++ if( arr[ i ] ) for( int j = i + 1; j < arr.length; j++ ) if( arr[ j ] ) return true; return false; } For Version 1 I say the running time is O(n) Version 2 I say O(n^2) Version 3 I say O(n^2) I am really new to this Big Oh Notation so if my answers are incorrect could you please explain and help.

    Read the article

  • What is the most efficiant way to get the highest and the lowest value in a Array

    - by meo
    is there something like PHP: max() in javascript? lets say i have an array like this: [2, 3, 23, 2, 2345, 4, 86, 8, 231, 75] and i want to return the highest and the lowest value in this array. What is the fastest way to do that? i have tried: function madmax (arr) { var max = arr[0], min = arr[1] if (min > max) { max = arr[1] min = arr[0] } for (i=1;i<=arr.length;i++){ if( arr[i] > max ) { max = arr[i] }else if( arr[i] < min ) { min = arr[i] } } return max, min } madmax([123, 2, 345, 153, 5, 98, 456, 4323456, 1, 234, 19874, 238, 4]) Is there a simpler way retrieve the max and min value of a array?

    Read the article

  • What is the most efficient way to get the highest and the lowest values in a Array

    - by meo
    is there something like PHP: max() in javascript? lets say i have an array like this: [2, 3, 23, 2, 2345, 4, 86, 8, 231, 75] and i want to return the highest and the lowest value in this array. What is the fastest way to do that? i have tried: function madmax (arr) { var max = arr[0], min = arr[1] if (min > max) { max = arr[1] min = arr[0] } for (i=1;i<=arr.length;i++){ if( arr[i] > max ) { max = arr[i] }else if( arr[i] < min ) { min = arr[i] } } return max, min } madmax([123, 2, 345, 153, 5, 98, 456, 4323456, 1, 234, 19874, 238, 4]) Is there a simpler way retrieve the max and min value of a array?

    Read the article

  • Why Hebrew letters in the address bar break the ARR gateway (Only With Explorer 8,9,10)?

    - by Noamway
    The ARR is working great in all browsers except Internet Explorer 8,9,10. When I paste Hebrew URL directly to the address bar it's working good, but when I surf (click on a simple href URL) from one Hebrew URL page to another Hebrew URL the ARR return me that error: "502 - Web server received an invalid response while acting as a gateway or proxy server." There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server. I checked it number of times including with HTTP analyzer and I saw that the "referer" is making all the problems and cause to that error. For example when I enter to that page: mydomain.com/somehebrewchars (mydomain.com/???? you will need Hebrew install) And click in the page on a link to: mydomain.com/somehebrewchars2 (mydomain.com/???????? you will need Hebrew install) I will get the error above and when you look at the referrer you will see something like that: mydomain.com/עמוד-× ×—×™×ª×” We use other proxies application to others projects and we don't have the same issue like that. For this example we used WIN 2008 and 2012 with ARR 2.5 and also 3 beta. Any help is welcome :-) Thanks, Noam

    Read the article

  • Problem implementing sorting algorithm in C with an array of structs

    - by dilog
    Well here is my little problem, first my code: struct alumn { char name[100]; char lastname[100]; int par; int nota; }; typedef struct alumn alumn; int bubble(alumn **arr, int length) { int i,j; alumn *temp; for (i=0; i<=length-2; i++) { for (j=i+1; j<=length-1;j++) { if ((*arr)[i].nota > (*arr)[j].nota) { temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } } } int main(int argc, char **argv) { alumn *alumns; ... here goes some other code ... bubble(&alumns,totalAlumns); return 0; } My problem is that this algorith is not sorting anything. I'm having a hard time doing the swap, i tried everything but nothing works :( . Any help??? struct alumn { char name[100]; char lastname[100]; int par; int nota; }; typedef struct alumn alumn; int bubble(alumn **arr, int length) { int i,j; alumn *temp; for (i=0; i<=length-2; i++) { for (j=i+1; j<=length-1;j++) { if ((*arr)[i].nota > (*arr)[j].nota) { temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } } } int main(int argc, char **argv) { alumn *alumns; ... here goes some other code ... bubble(&alumns,totalAlumns); return 0; } My problem is that this algorith is not sorting anything. I'm having a hard time doing the swap, i tried everything but nothing works :( . Any help???

    Read the article

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