I created a new website in IIS called wbsite1. Then I added an application to website1 wich is a website called website2. The problem appeared when we tried to access links in website2. The browser always refers to the root url and redirect so we were trying to change all the urls in website2. For example, if we have a url in website2 like :
<a href='http://localhost:2030/website2/cms/default.aspx...'
and we click on that link the browser redirect us to :
http://localhost:2030/website1/default.aspx
Why am I getting this behavior? And what is the best workaround to integrate two websites without trying to mess with every link in the website? Thank you very much.
We are facing troubles when I try to access a page in the child application it redirects to the default page of the main application and gives the error:
Session state is not available in this context.
I found the solution for my question and it's this :
unfortunately i have to "rewrite" all our links in my code.
so i created a function which will automatically add prefix to external links,
and store base link for other site it configuration.
I did such project with success. thank u for all your replies
i found another solution also and it's using a web proxy but i can't use it in my scenario
Related
I included BotDetect Captcha in my login page but the captcha control is not loading. I tried a simple page based on examples but still captcha is not working/loading
Here are the config lines : webconfig
Your help is highly needed and appreciated
You can try reCAPTCHA which have provision to run on local
"If you would like to use "localhost" for development, you must add it to the list of domains."
Even though it allows to run on local server but can only work if you access localhost using 127.0.0.1 rather than localhost.
Here is the reCAPTCHA .link for reference
I'm a newbie at asp.net and I have asp.net application with nested master pages. (.Net 3.5) I had a web form at root directory and I moved it a folder which I created under root. From this point I started to get "cannot use a leading .. to exit above the top directory" error while that web form loading. I digged on web and I tried prefixes "~", "/", "../" but I'm nowhere. my code as follows.
<li>
Add New Staff
</li>
I tried to create one more web form under "Staff" directory, but this form also generates same error while loading. Appreciate for help.
if i am not wrong you are using double code in href. it should be like this depending on your folder structure.
Add New Staff
And
For anyone who has found this thread, addressing relative paths has always created arguments over what is correct or not.
Depending on where you use the path to be addressed, it will depend on how you address the path.
Generally :
. and ./ do the same thing, however you wouldn't use . with a file name. Otherwise you will have the browser requesting .filename.ext as a file from the server. The proper method would be ./filename.ext.
../ addresses the path up one level from the current folder. If you were in the path /cheese/crackers/yummy.html, and your link code asked for ../butter/spread.html in the document yummy.html, then you would be addressing the path /cheese/butter/spread.html, as far as the server was concerned.
/ will always address the root of the site.
In ASP.NET Web Form, we normally use HyperLink server control to create URL as mason said.
<asp:HyperLink runat="server" NavigateUrl="~/Staff/New_Staff.aspx" Text="Add New Staff"/>
If you do not want use it, you can manually prepend with <%= ResolveUrl("~/") %>.
Add New Staff
I have a very basic Single Sign On app built on VS 2015 using MVC and Web Forms. It is supposed to be a simple proof of concept and is based on some code found here and here which are essentially the same things. I've finally gotten it all converted to use .Net 4.5 but when running it on my local server it throws a 404 with no debug information.
The 404 itself wasn't initially a surprise as I was supposed to be able to change the url to one of the secure pages (for instance /WebSecApp1) which would redirect me back to the signon page but no matter what I put as the url I get the 404.
I've also tried changing the urls in the code so that they contain the port numbers for the localhost but that doesn't work either.
It was suggested to me that the RouteConfig.cs could be the culprit but I don't see how that could be since I'm calling a single page with no parameters.
I know this is kind of lite on details but does anyone have any suggestions?
Yes this looks like a routing issue as you also thought it to be. Routing is essential for web api too .Pls see https://www.asp.net/web-api/overview/web-api-routing-and-actions/routing-and-action-selection. Does your api request look like this
GET http://localhost:34701/api/products/1?version=1.5&details=1
You do have to mention the port in the request.
While the routing that Arathy mentioned above was partially to blame, the real problem turned out to be relatively simple. In my case simply selecting Properties->Web for each of offending pages and setting "Override application root URL" to checked fixed the whole problem.
I'm facing a really weird scenario here with my local IIS. I have hosted multiple sites in the default website in my local IIS. One of them has the login page. From the login page, I'm redirecting the user to another page that is located in another site (which is also hosted in the same IIS inside default website virtual directory).
Now in the submit button click event of my login page, after authenticating the user, I have written a "Response.Redirect(redirect_url)". the redirect_url is being formed dynamically and given as a parameter to the Redirect method.
While debugging, the final redirect_url that is being sent as parameter to Redirect method is:
http://localhost/CP/web/console/console.aspx?sk=3e3cc1a8-73c4-4945-b3f8-08af22ea4324.50008
But after I try to go to the next step, I'm suddenly getting a HTTP 404 error saying that the resource doesn't exist and I have observed that Requested URL shown in the error page is different that what was dynamically sent to the Response.Redirect(...) method.
In the error page, the requested url shows the value as
http://localhost/CP/web/console/localhost/CPLogin?err=5
whereas my actual requested url formed in the code is:
http://localhost/CP/web/console/console.aspx?sk=3e3cc1a8-73c4-4945-b3f8-08af22ea4324.50008
I'm just unable to understand why the requested url is getting changed automatically.! Also, I observe that "localhost" is being appended to the requested URL again which is not what is supposed to happen.
Please visit THIS link[^] to understand this question more clearly. I have added screen shot of the error page.
http://amoghnatu.wordpress.com/2013/09/16/question-please-help-iis-throwing-http-404-not-found-but-requested-resource-actually-exists-requested-url-also-changing-automatically/[^]
Thanks a lot.!
Indeed, the problem was with the way I had hosted the sites in my application. I just removed all the sites related to my application from IIS and then hosted all of them again much more carefully. This resolved the "wrong redirect url" problem.
Also, I had some tables with missing required data because of which I was getting the error code.
So after I got all the tables filled with the required data and also after properly hosting the application in IIS, my problem got resolved.
In IIS, go to relevant folder, right click and "browse". Check out what is the URL. In most cases, this is due to the URL should have port number appended. For instance it will be something like :
http://localhost:<port number>/CP/web/console/console.aspx?sk=3e3cc1a8-73c4-4945-b3f8-08af22ea4324.50008
instead of
http://localhost/CP/web/console/console.aspx?sk=3e3cc1a8-73c4-4945-b3f8-08af22ea4324.50008
I have a subdomain that is http://trade.businessbazaar.in . I am dynamically creating urls from database something in this manner http://trade.businessbazaar.in/mycompany. To display details, I have an index.aspx file there,thinking that on every request the index.aspx page will load and display data accodingly. Also, There is a masterpage on the index.aspx page from where i am capturing the text mycompany and query it in database to fetch result. But nothing seems to work.
A genuine link is http://trade.businessbazaar.in/Symparlife. But its unable to load index.aspx. I need a clean approach without any third party dll or rewriters. Directly to push some lines in config and start working. That is url will be the same but index page will get loaded...
In short, i want to say
I need the StackOverflow type clean url mechanism to fetch pages
Thanks in Advance
You can handle the Begin_Request event in Global.asax and add custom code to redirect to index.aspx and convert the parts of the URL into query string arguments. You should use Server.Transfer to keep the URL in the browser.
I'd recommend upgrading to 4.0 and using the Routing enine though. You should check if the standard routing is available as a download for ASP.NET 3.5. I am sure your code will get messy very soon. Been there, done that.
As #Mike Miller mentions in the comments the Routing engine ships with ASP.NET 3.5. You can check the documentation here - http://msdn.microsoft.com/en-us/library/system.web.routing(v=vs.90).aspx
Here is a tutorial on how to use it with Web Forms - http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx
For your case the code would be something like:
routes.MapPageRoute("company-index", "/{company}", "~/index.aspx")
And in index.aspx you can access the route value for company like this:
string company = (string)Page.RouteData.Values["company"];
Keep in mind that you'd better add something in the URL before your actual argument (the company name). If you don't you will have problems later on when because you may want to add a URL like "/Login" but then you will have to validate that users can't create a company named "Login". Not how Stack Overflow has "/questions/" before the actual question info in the URL.