how to simulate a cross origin site on local machine? - asp.net

I am trying to simulate a cross origin site. Meaning I shouldn't be able to make ajax request from site A to site B since the browser will not naturally allow me to do so because of their cross-origin policy.
What are the tools I can use in this regard? Or are there any hacks?
What I've tried so far: I've opened a visual studio solution. It has two asp.net web form projects. One web project (say A) simply hosts a form with a file input control and a submit button. The other project B has a simple aspx page, which contains an iframe which loads site A inside of it.
I ran project B, and, in the browser console window, I did something like this:
var ifr = document.getElementById('myiframe');
console.log(ifr.contentWindow.document.body.innerHTML);
The console window displays the markup of site A's page which is loaded in the client's iframe.
Clearly I've failed. But is there I way I can do it on one machine.

Well, a bit of digging shows that you can achieve this feat is by modifying your hosts file (C:\Windows\System32\drivers\etc\hosts) as mentioned in the post below:
How do i map http://localhost:8080 to http://mysites in iis7?

Related

How can I test accessbility using Lighthouse on a single page application

A colleague showed me Lighthouse on the Chrome browser. I have a single page application (SPA), and I'm able to run it against the base URL of my application.
However, all subsequent screens are rendered by client-side JavaScript without a change to the URL in the browser.
How can I test the rest of my site?
The only way is to switch project to server side rendering, like Angular Universal
update: found this issue https://github.com/GoogleChrome/lighthouse/issues/5187
If you can't switch your project to server side rendering as Alexey Semerenko said, you can consider using another testing tool like Sitespeed.io which allows you to define user actions as a script to browse every pages of your application.
After your test you will gather the same kind of metrics.

.ASPX pages markups are opening in web browser

When I double click on .aspx pages in my web application project in VS2010, instead of showing the mark up in the ide the .aspx pages are opening in the web browser as shown below. The same is happening when I run my application it opens all the .aspx pages in the web browser along the application url i.e., http://localhost123456/default.aspx. I have to close all the other pages except the http://localhost123456/default.aspx to run/ test my application. Not sure what would cause this to happen. I am not able to find any solutions so far, any help is appreciated. I used the option View Markup (Rightclick on aspx page -> view Markup) to see the markup for now.
Update
As per Mike's answer I checked the options under Open with... and I do have a Internet Explorer (Default) set as shown in the following image. Not sure how did it got there.
Deleting the Internet Explorer (Default) option might be cumbersome if I have lot of .aspx pages , if there is a way to remove this option at once for all .aspx pages rather than right clicking on each and every .aspx and remove it that would be great.
As per #JB King suggestion I did checked the file properties and all the .aspx files are set with Opens with: Microsoft Visual Studio option as shown it the image below.
Right-click any .aspx file in the project, select Open With...
In the screen that pops up, select Web Form Editor, then click the Set as Default button.
Not sure how you got Internet Explorer as an option here, but if it is there, you can just delete it. It's not applicable for loading the aspx from disk. Rather, to see the rendered page in IE, you'd do View in Browser or Browse With... (in which you can set your default browser, as well).
Your address bar shows you're loading files directly from disk. This won't work. ASP.NET is not lilke static HTML. ASP.NET applications must be run from within a webserver. Install IIS and ensure ASP.NET is installed and configured, or use the Debugging Webserver (IIS Express) in Visual Studio.
If you look at the properties of the file, there should be a line of Opens with: that is where you want to have Visual Studio rather than Internet Explorer as the issue is with which programs are mapped to what file extension. Microsoft instructions if you want those as specific steps to do.

Advanced web scraping

I want to scrape a part of a website, lets say: www.mywebsite.com/x1/x2
The website needs login information.
You need to open x1 first then you click on a button and x2 will be opened as a popup window. If you close x1 you lose access to x2.
I used Internet Download Manager, and I think I correctly put login information but this failed because you need x1 to be opened when you access x2.
The website support JavaScript.
IDM (after I've looked at) is for downloading, not for regular web scraping. Why not to use a special web scraping software? Most of them support logging in and complicated html and js-driven pages scrape. Seems to me your case is not a pure html page but a js-stuffed web page.

IIS smooth streaming does not play a video on asp.net MVC 4 with Razor

I am trying to get a basic demo working but can't succeed, I've spent hours and hours on it..
I am building an iis smooth streaming player with no controls at first that auto plays the video, I am using "MMP"- Microsoft media platform which was formerly "SMF"- Silverlight media framework, the example I am using to build a smooth streaming player is here on the middle of this page: http://smf.codeplex.com/documentation
A brief explanation of the issue I am facing:
I am sure I got everything right in terms of the player itself, I got the .ism file, i can view its manifest if I browse to it with the browser, I can even get everything to work and play the video in an html file that is running straight from an IIS website.
another key note: I can also run any test silverlight application for example, the main form with a button and a few radio buttons and I do get this application to run and display. the problem happens only when I try the smooth streaming player, it gives a black and blank page for the whole page and right clicking shows "silverlight".
so the problem starts when I try to run it from a Silverlight application that is hosted in an asp.net MVC 4 (with Razor) application.
I have an asp.net MVC project in visual studio and then I add a silverlight application to it and choose to host it in the MVC application, then I follow the same routin as for the silverlight application player building and it even renders and plays the video on the visual studio's silverlight XAML design page. I build the whole solutio and then I get a "silverlightApplication1.xap" file in a "ClientBin" new folder on the MVC application and also a test html file and an test aspx file again in the MVC application.
if I make sure the linking is correct I can take this html file to another IIS website and run it from there and it works and plays! but if I try to run it straight from within the application (view in browser) for the html/aspx files it says that it's not running on the platform/fabric of the website and for the silverlight application itself it opens the same blank silvelight application with a black screen and also a URL of file:// and not http://localhost.. etc', so what I was trying to do for a long time is to make the silverlight application work as a view in the MVC application.
so I took a view and deleted everything in it and gave it a property of Layout=""; (nothing) and then I put the content of the test html file the SL application produced earlier, modified the value for the silverlightapplication path etc', when built and ran, the page comes up, even the application comes up as I see "Silverlight" on a right click of the mouse but the whole screen is just plain black again and it doesn't play the video.
I had the .ism file on anther location or a an entirely different location like another online website.
I also can't get to view the manifest when I run the MVC application it says its 404 but I am not sure if it's an MVC platform thing that it won't let me get to it or it's just not getting to it but the files are there and the URL's are correct both in the code and also in the URL i am putting in.
I have also came to the understanding that I might need to make sure the silverlight application is allowing cross domain traffic and it has a Client access policy like seen on this page: http://msdn.microsoft.com/en-us/library/cc838250(VS.95).aspx , so I've added two XML files to the root folder for these two issues. trying to figure out what's going on with firefox's web developer gives nothing as for what happens..
Please Help! Thanks! :)
Ray.
I don't know why and I have tried everything+making sure I get the manifest content if i browse to it.
it just worked with this URL for the ism file:
http://video3.smoothhd.com.edgesuite.net/ondemand/Big%20Buck%20Bunny%20Adaptive.ism/Manifest
there was no need for cross domain xml and Client access policy xml.

can we see html localstorage content through client browser?

supppose I use html5 local storage for my website.
1)can End user see my local storage values through browser using view source code etc?
2)How can we enter data for HTML5 local storage as domain level, i dont want to add my records manually when page loads everytime?
3where will HTML5 local storage content be saved?
I)in client side?
II)in server side(webserver)
anyhelp please?
Not through view source, but many Developer Tools support this. So yes, a user could very easy figure out what the contents of their browser's localStorage is. For example, in Chrome, open the Developer Tools, and on the Resources tab select "Local Storage"
I think what you are asking for is "How to I add local storage without writing the code in every page". You would typically then put that code in a common .js file - and reference it whenever you needed it. If you need it in every page, then depending on which platform you are using, they probably have some sort of "master". ASP.NET WebForms has Master Pages, ASP.NET MVC has ViewStart, etc.
Client side. It's local storage - as in it is local to the browser.

Resources