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
Related
I need to just search Yammer for a various string on the timeline and facing a few weird issues.
Using Nuget, I got the yammer.simpleapi package (Found the bug everyone was talking about and changed it from GET to POST) and I created an App on Yammer, but, this is where the fun starts.
I have a local page http://localhost/home/yammer which redirects to Oauth and then redirects to my app with the key and I retrieve basic user settings.
Now, this is where I get confused - I see if I refresh this page, I just get a blank response (I guess that the code is only good for one query?), but if I refresh the http://localhost/home/yammer - I sometimes get the correct response and sometimes I get nothing.
This is best shown in a recording I did - https://youtu.be/RqrAGiP7Rh4
This is really annoying me and I was wondering if anyone knows what is going on?
I would post code examples, but, there hasn't really been anything modified from the original yammer.simpleapi other than the keys.
The web example app is just working one time.
If you want to replay your page, you should save your YammerClient somewhere (or declare it in static)
Does anyone know good sample code, using ASP.net security, that sets up a sample Visual Studio 2010 application, along with a log in page, and the logic/code to verify users who sign up via email? I feel like this must have been written thousands of times.
I will give you the URL that I started with. You can go form that to a different approach if you like but that is well explained and you can understand what you need to do:
http://forums.asp.net/post/1860807.aspx
please notice that the example there is old and you will need some ADO.NET understanding but the idea is the same
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 am finding a good way to implement Page Counter Statistic for internal web application (so maybe I can not use Google Analytics to help me).
I want to find out which page in my web application that user does not visit anymore. So I can investigate the reason why there is no hit to that page. If it has a bug or that page is not necessary anymore.
The easy way that comes to mind is to add every page with some line of codes to update the page page view. But there are so many page in my web, so this will take a lot of time.
So is there any other way to make a simple web page statistic with minimize line of codes.
For more information
- Every user have to log in before using this web.
- There is session to store user's ID.
- I use .NET 1.1 as an environment and plan to migrate to .NET 2.0+ in the future.
- Page stat is not show on web, I just want the hit count and then analyze it.
Google Analytics is probably your best bet. Although your site is internal, Google Analytics will still work so long as you are able to hit their server from within your network. I've used it on intranet sites before without any issues.
You use ashx files and invoke it via markup (i.e. as a jquery invocation or as using an image tag) or you add an HTTP module. Both can be implemented without recompiling-- just adding one more .dll to the bin and editing the web.config. There is not enough space in this text box to give full justice to the steps necessary to write a http module or handler and a hit counter.
Im looking for the best way to change the URL to pages based on who is logged on, the limitation is all the pages are PRE generated so the actual html will already be generated and cannot be generated again on a pr user basis.
Posible solutions
A posible solution might be to use javascript to basicly add to the end of all URL ?=MyUserName , but im unsure if this will work with all spiders ( By all i mean the major search engines). This solution feels a bit dirty to me..
There might also be some way of of when the request comes in to then basicly say that response is from Default.aspx=?Username with doing a response.Redirect?
Its also importent to remember i will be changing the cache settings based on this, like saying if your not logged in the page can be cached.
I'm not sure if you must use .html files or another specific extension, but you could always create your own handler and process what you want to do on every request that way. Your handler would determine who is accessing the page and then do a Response.Redirect (or whatever action is necessary).