I am facing a problem that is driving me crazy. I will try to be simple about the issue.
I have a project that uses MVC and Angular. The project has a page layout to signin and another to use in main project. I can't change the way the users access the pages, so I need to create the routes the same way they are using.
I want to change the mvc route to use different actions to use the correct layout, one is for signin and the other layout to the main app. The examples below:
To access the signin page: {mainurl}/#/signin
To access another signin page, but for support, using the same layout as signin: {mainurl}/#/signinsupport
To access the main page, after signin: {mainurl}/#/main
How can I change the mvc route to access these different pages using the urls above? Is there an easy way to do that?
Thanks a lot for your help!
Related
I have Asp.net application.
I want to integrate another Asp.net MVC application to exsting Asp.net application.
So I did the following changes.
1.I added area in exsting Asp.net application.
2.Added path in routeconfig.
3.Now How to call Asp.net MVC Razor ??
Controller Name-Home
Action Name-Home
How to call Home page inside MVC Area from js file present in asp.net project.
Thanks in advance !
it's same as calling other page.. just you set up the proper routing structure in order to render the view.
document.location.href='yourArea/FolderName/Home/Action';
or you can use an HyperLink to achieve the same
MVC view
If you only want to call method, then simple way is Response.Redirect("~/ControllerName/ActionMethodName");
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
I have a web application using Enterprise Web Library and I've found the need to have a custom log-in page. I see that EWL provides one for me, but I want to be able to have some custom elements on the page and control how the user is logged in. How can I achieve this in EWL?
First, create your custom log-in page. Let's call it MyLogIn.aspx.
The next step is to designate MyLogIn as the log-in page for some/all of the pages and shortcut URLs in your app. To do that for pages, override PageInfo.LogInPage and/or EntitySetupInfo.LogInPage and return a MyLogIn.Info reference. This setting is inherited from parent pages and entity setups. If you want all pages in your app to use MyLogIn, you only need to override the LogInPage property at the root of your page tree.
To use MyLogIn for your shortcut URLs, use the logInPageGetter optional parameter in the ShortcutUrlResolver constructor. Pass a function that returns a MyLogIn.Info reference.
The final step is to implement MyLogIn. You can design the page however you want and collect whatever credentials you want, but there are a few things you need, which depend on whether you still want to use EWL's UserManagement subsystem. If you do, you need to call UserManagementStatics.SetUpClientSideLogicForLogInPostBack during LoadData and call either UserManagementStatics.LogInUser or UserManagementStatics.LogInSpecifiedUser from a DataModification. If you are not using UserManagement, you're responsible for authenticating the user in your own fashion as part of a DataModification, before redirecting the user into the app.
I have an existing Web Site that uses multiple ASP .Net Web Forms projects. I have created an MVC 4 mobile web application to replace the login/ authorization web form project.
So far I have been able to replace all the functionality of the site, except I am unable to redirect to the ASP .Net pages from inside the Controller.
Using this method I can reach other MVC applications on the same web site without issue:
return Redirect("MyURLstring");
However when I redirect to a Web Forms page I receive several JS errors, and the Page never redirects. It looks like the MVC application is attempting to apply JQuery 1.7.1 to the URL that is being opened.
I can reach the URL without error if I include a rel="external" tag within a hyperlink in a view.
I have also attempted to solve this by creating a route in my RouteConfig.cs file
RouteValueDictionary RouteValues = new RouteValueDictionary();
RouteValues["rel"] = "external";
return RedirectToRoute("MyRouteName", RouteValues);
Any help is greatly appreciated.
Solution:
I created the project as a MVC 4 Mobile site as a base, but still had the referencing to jQuery Mobile in my main _Layout view.
#Scripts.Render("~/bundles/jquery", "~/bundles/jquerymobile", "~/bundles/jquerycustom")
I kept this code intact for my _Layout.Mobile.cstml view, but changed to below for _Layout.cshtml
#Scripts.Render("~/bundles/jquery", "~/bundles/jquerycustom")
This allows me to perform a return Redirect("myURL"); from the controller without hopping through all the jQuery that was preventing the redirect.
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.