I have a C# Windows Store App with a WebView which loads some local HTML. I do this via the NavigateToString method. I want to include jQuery but so far the only way I can get this to work is either using the ajax hosted libraries or pasting the entire library into a script tag on the same page.
I've tried putting it in the Assets folder, ensuring that its set to Content / Copy If Newer, and I've tried the following paths to it with no success
Assets/jquery-2.1.0.min.js
/Assets/jquery-2.1.0.min.js
./Assets/jquery-2.1.0.min.js
~/Assets/jquery-2.1.0.min.js
ms-appx:///Assets/jquery-2.1.0.min.js
I've tried putting it in a /js subfolder in the app, as I've seen this done in some examples online. I've also tried adding JQuery through NuGet. Neither of these steps really made sense to me and they obviously didn't work, but I thought they were worth a try.
As usual, I got the inspiration to try one more thing while finishing up my StackOverflow question. This works:
ms-appx-web:///Assets/jquery-2.1.0.min.js
This URI Scheme ms-appx-web is mentioned in this msdn post, but it doesn't explicitly state in which cases it should be used over ms-appx:. I guess accessing local resources from a WebView is one of those cases.
Related
Following this answer, I've enabled serving JavaScript and CSS from my Views folder which is helping my project's organization. Unfortunately, while I'm developing, I find I have to disable my browser cache in order to see my changes. I'd like to be able to develop without keeping DevTools open just to disable the cache.
I figure my issue is the System.Web.StaticFileHandler serving up the files in such a way that the browser caches them. I've tried using System.Web.Handlers.TransferRequestHandler like this answer suggests, but then I get 500 Server Errors instead.
Is my understanding of the problem correct? How can I resolve my issue?
Note: Not that it's relevant, but I intend to add a config transform to switch back to the static handler for releases.
I am using AngleSharp in C# to simulate a web browser. For debugging purposes, sometimes I want to see the page I am traversing. I am asking if there is an easy way to show the current document in a web browser (preferably the system's default browser) and if possible with current cookie states.
I am very late to the party, but hopefully someone will find my answer useful: The short answer is no, the long answer is, yes - with some work that is possible in a limited way.
How to make it possible? By injecting some code into AngleSharp that opens a (local) webserver. The content from this webserver could then be inspected in any webbrowser (e.g., the system's default browser).
The injected local webserver would serve the current document at its root (e.g., http://localhost:9000/), along with all auxiliary information in HTTP headers (e.g., cookie states). The problem with this approach is that we either transport the document's original source or a serialization of the DOM as seen by AngleSharp. Therefore, there could be some deviations and it may not be what you want. Alternatively, the server could emit JS code that replicates what AngleSharp currently sees (however, then standard debugging seems more viable).
Any approach, however, requires some (tedious?) work and therefore needs to be justified. Since you want to "see" the page I guess a CSS renderer would be more interesting (also it could be embedded in any application or made available in form of a VS extension).
Hope this helps!
Using ASP.NET 4.0, IIS 7.5.
I have a website engine, I have just implemented a way for this to tell if it's being loaded on mobile and instead of loading Controls\MyControl.ascx it loads Mobile\Controls\MyControl.ascx. This works well for my controls and also my MasterPage.Master file.
What I can't figure out however is how I can do the same with Default.aspx. This needs to be done on the fly programatically as I need to be able to check if it's mobile version. I was thinking of doing something on a pre-init event in globals but not sure if that's the best way.
Note: I don't want to use inline code on Default.aspx and just display different content base on my Mobile flag as my scenario goes one step further by basing the file on customer as well and this would mean having one huge Default.aspx for all customers which wouldn't be manageable.
Changing the default document on the fly is not possible in any practical sense.
Writing to the web.config on the fly to load a mobile version of a default page is quite frankly terrible and not an answer to the true context of your issue. I would feel irresponsible as a developer if I even proposed this as an answer to loading a mobile version of a default page.
I was trying to help you solve your problem and not just answer the base question in the title. As we all know, changing the web.config will restart your application and would not serve as a true solution, as you could not do this and achieve any kind of performance.
Here is the BEST alternative (IMHO) to dealing with mobile browsers.
http://51degrees.codeplex.com/
HTH!
For anyone else looking at this I have found a solution but I am not sure I will implement it as I don't like the idea of updating the web.config file at run time. Using the Microsoft.Web.Administration namespace you can update the server.webServer -> defaultDocument section programmatically. Doing this allows you to change the path to default.aspx and it will load based on the variables you set.
This link should provide more information: http://blogs.msdn.com/b/saurabh_singh/archive/2007/11/24/accessing-iis-7-0-features-programmatically-from-configuration-file-s-c.aspx
Also, the Microsoft.Web.Administration dll isn't available directly in VS so you need to add it from %windir%\syswow64\inetsrv (64bit version).
I was building something using jQuery's AutoComplete plugin last week, but today I found that it's not working.
After some debugging, it seems that the external scripts I've been loading no longer exist:
http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.bgiframe.min.js
http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.dimensions.js
http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.js
Even the demo on the plugin page no longer works:
http://docs.jquery.com/Plugins/autocomplete
Was the plugin deprecated over the weekend and I didn't know it? Or is there some way to let them know that the files aren't showing up?
Here's a link to the static delivery on the google CDN:
http://code.google.com/apis/libraries/
I'm not sure they do the plugins, but you can get the main library this way.
Here are some quick links to get your missing scripts:
http://docs.jquery.com/Plugins/bgiframe
http://plugins.jquery.com/project/dimensions
http://docs.jquery.com/Plugins/autocomplete
Like #Paddy said in the comments above, I would HIGHLY recommend pulling these down into your project and creating local references to each instead of relying on the FQDN of the scripts on another host to remain unchanged forever.
UPDATE:
Note that I myself have noticed some downloads going missing recently on jquery.com, so you may have trouble finding the downloads. If so, I would recommend checking if google's cache has a hard link to them - I've been able to find a couple this way.
I need to create and add custom headers to an ASP.NET 2.0 application.
The case is simulation of an SSO-login in our dev/test environment.
When I try to add headers I run into the "Not supported on this platform."
error. BigJim has a nice post on the subject here:
http://bigjimindc.blogspot.com/2007/07/ms-kb928365-aspnet-requestheadersadd.html
The root of my problem lies in the fact that I need to simulate various
persons logging into my application. Not just adding static data in a
HttpModule. I need to take values from a couple of TextBoxes and transfer
information from these into custom headers and then re-direct the user. The
HttpModule stuff happens to early in the pipeline...
Does anyone now if there exsist a simple redirect/proxy solution that one
could use in a dev environment? Or have simple/beautiful way of doing it in code?
One method i have used before, though a long winded approach, is NUnitASP.
This is based on the NUnit framework but intended for ASP.NET UI Testing.
It basically starts a browser in memory, and is able to manipulate the content exactly like a user would.
Using this you could view your page, enter data into textboxes and submit pages.
Hopefully that can help you do the testing you require. I've used it to test load, and spider through sites of mine to gather data.
If you use IIS 7 you can set the Pipeline Mode to integrated
This Setting is found in the App-Pool Properties.
I could be wrong, but doesn't the Response.AddHeader() method still work? Although, I agree with Oscar that a formal testing solution like NUnitASP is a good idea. Although, NUnitASP is a little dated. I still use it for some of my projects just because it still does work; it just isn't as refined or as simple as WaTiN or similar projects.
The browser drops the header if you do a Response.AddHeader()...
The header must be added to the orginal Request...
why don't use ASP.NET forms authentication model?
you define your "private folders". if you attempt to acces to a private folder without login, you automatically are redirected to a your custom login page.
here's a couple of link:
http://support.microsoft.com/kb/301240
http://www.asp.net/learn/security/tutorial-02-cs.aspx