I am trying to create url routing like this
http://msdn.microsoft.com/en-us/magazine/dd347546.aspx
but I am having few questions , first why he is adding lines to the web.config , I tested it and it didnt appear that they're doing something as I commented them and nothing major appeared
second I am having this line of code that is crashing
var display = BuildManager.CreateInstanceFromVirtualPath(_virtualPath,typeof(Page)) as IProfileHandler;
when casted as ihttphandler it's working , but when I am casting it to iprofilehandler(which is implemeting ihttphandler) it's giving null !
This article is quite old as it's written before ASP.NET 4.0 was released.
Routing is now a core component of ASP.NET 4.
See this one instead:
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
These are really two questions here:
Why he is adding lines to the web.config - Web Configuration in .NET 4.0 applications has been greatly streamlined. A lot of the configuration that was done per-application is now included in the lower level web configuration (machine wide) (read). This means you don't need to add that configuration data in, its already done for you.
You're issue with BuildManager returning null. We'd need to see a little more code than that.
Related
Let's be clear, I don't really like WebForms. Which is why I do not wish to spend hours debugging a legacy code base that ran perfectly well on one server (IIS7) and a new one (IIS8).
I heard there is this new ClientIDMode, which makes forms and other controls change their IDs or not to something sensible, but I didn't touch it. It seems like the default value has changed (ie is not backwards compatible)?
I had a form in a master page that looked like <form id=SiteForm runat=server
This automatically changed its ID to aspnetForm in the rendered output.
Sure it was a bit weird, but I have a lot of code in this app that relies on it. I could simply change the ID in the server page to <form id=SiteForm runat=aspnetForm and that might fix it. But maybe there's some code in this old project that uses SiteForm on the server side, so I can search for that.
But there could be other controls lurking around which had their IDs changed too. So maybe there is something I can add to the web config to turn the behaviour back to what it was before? What was the default before?
UPDATE: Looks like when exporting and importing the app pools this site somehow got changed from .NET2 to .NET4, so perhaps I just need to set it back to .NET2?
I found that I had not ticked the box to install .NET 3.5 within IIS setup. This is why all my app pools reverted to .NET 4 automatically and why these weird changes happened. So I installed it in IIS, restarted, and set the app pool to .NET 2 (ie 3.5). This fixed it, cleanly, so I will call that the solution.
I have a MVC5 project using signalr to perform updates to a list. Inside script.js, there is a variable link to defined as var link = $.connection.hub. There is also a bundleconfig file to load the dependent scripts, signalr/jquery and jquery in the proper order of course.
The script /signalr/hubs is loaded in from the html manually.
bundles.Add(new ScriptBundle("~/bundles/signalr").Include(
"~/Scripts/script.js",
"~/Scripts/jquery.signalR-2.0.2.min.js"));
When the VS 2013 Web project is run, it works fine until the project is copied over to another PC that it does not work as intended. The variable link is undefined as $.connection is undefined too ($ is defined though).
I presume that jquery.signalR-2.0.2.min.js is not read or executed at all.
Questions:
Might this have anything to do with the environment of the PCs? (Windows 7 is OK, Windows 8 is not OK)
What could prevent jquery.signalR-2.0.2.min.js from running?
Does creating a new View/Controller play a part in the error (creating a view, using a layout page)?
Please see similar question: SignalR and MVC bundle as it shows how to add SignalR into an MVC bundle. I think their answer should help solve your problem.
I would comment instead of answer, but I don't have enough reputation.
I need to migrate my website which was earlier in target framework 3.5.
Now i need to convert it into 4.5, Please tell me that best approach to do it.....
I have tried with visual studio 2012 'Build' option to change it to 4.5.
But i am getting lots of script resource error mainly in js file, although these all works fine in 3.5.
After changing it to 4.5 , I m getting so many java script errors.
So, i am missing something.
Need to discuss these errors with you, so currently i am not including any error with you.
Please help me for the the right approach for this.
Any kind of help will be highly appreciated.
Thanks in advance.
You may have problems with some of the HTML elements you have marked as runat="server", specially iFrames.
So, if you a line of code (in you code-in-front) that looks like
<iframe id="myServerSideIframe" runat="server" src=""></iframe>
you are going to have problems loading them.
The reason is that the type of the corresponding variable in your code-behind for most of the HTML elements is "System.Web.UI.HtmlControls.HtmlGenericControl". However, in .Net 4.5, there are specific types for each HTML element, e.g. System.Web.UI.HtmlControls.HtmlIframe.
In order to resolve this, one easy way is changing the Id of that element in code-in-front, and changing it back to the original Id. That way, the designer will automatically update the variable declarations in the designer file.
Had converted web app from 3.5 to 4.0 (and then to 4.5)
When you open your app in VS2012, it will offer to migrate it to .NET 4.5.
Let it do the migration; most of the changes are in the web.config.
Refer to http://www.asp.net/whitepapers/aspnet4 and http://www.asp.net/vnext/overview/aspnet/whats-new for an overview of potential "breaking changes"
You may have javascript problems with ClientID; ClientIDMode=AutoID or static may help.
If you are using 3rd party .NET assemblies, some of them may not work properly.
You will have to check with the assembly author for new updates.
Good luck on the migration.
I've just started developing silverlight applications. I've created a webserivce in my asp.net project. Now, when I try to connect to it through my silverlight project I receive the following error:
"the opreation is not supported for a relative uri"
I am using the following url -->
http://192.168.1.2/MyWebsite/SubVersionedHistory.svc
I can find the class and its methods, but I receive this horrific error when I add it.
Thank you for your help and advice,
Vondiplo
I don't think you're alone in hitting this problem. I hit it today with VS2008SP1 + SL2 trying to create a Service Reference for an ADO.NET Data Service. First time I've hit the error.
Others have detailed similar experiences to reach this error:
http://silverlight.net/forums/t/87535.aspx
http://silverlight.net/forums/t/56629.aspx
It's not entirely clear at this point if the issue is with the IDE "Add Service Reference" dialog or something specific in the services causing this error. In my case, however, my code still worked despite the error message. I simply passed the URL to my service in the constructor of my DataService proxy client, like this:
var context = new DataServiceContext(new Uri("NorthwindDataService.svc", UriKind.Relative));
Summary point: Just because you hit this error in the IDE, your service reference may still work. Give it a try and let us know if you're seeing errors at run time.
Hope that helps.
[UPDATE] Based on some other advice I've found and tested, you can also try:
deleting your Service Reference
deleting your ServiceReferences.ClientConfig file
saving your solution
and then closing and reopening it in VS.
The simple act of closing and reopening your project has been shown to fix several problems with the Add Service wizard. Re-run the Add Service Ref wizard and you may have better luck. I personally tested this solution on a project today and can confirm it works. Hope that adds extra help to finding your solution.
You should be more specific about your problem. For example, are you having this problem when adding the reference or when you actually try to consume the service?
It sounds like you need to be using a full path, including the "http://" but that is just a shot in the dark based on the error message you provide.
[edit]If you are using the built in ASP.NET server instead of IIS then be sure you set a specific port number and use it in your path. For example, I have used http://localhost:4940/MyService.svc for testing[/edit]
Maybe this response can help you
You cannot use AbsolutePath, You need to use AbsoluteURL. Build your URL this way:
Uri url = new Uri(App.Current.Host.Source, "../settings.xml");client.DownloadStringAsync(url);
http://silverlight.net/forums/p/28912/95541.aspx
HTH
Braulio
Check the ServiceReferences.ClientConfig
if there are multiple endpoints there you will get this exception. one thing that can cause this is referencing a service using casini, later switiching to IIS express and rereferencing the service.
I have an ASP.NET application originally deployed to a .Net 1.1 Framework on Windows 2000 server which i'm now using on a Windows 2008 Server using 2.0.50727. We use the tilde (~) to resolve to an absolute path in many areas of the application and it works for things like asp:hyperlink controls (with run-at server tags), but for our bound datagrid controls which are using HyperLinkColumns to create links based on ID values returned from our database, the tilde is getting written to the page.
This code:
HyperLinkColumn oLink = new HyperLinkColumn();
oLink.DataNavigateUrlField = "IdField";
oLink.DataNavigateUrlFormatString = "~/Here{0}.aspx";
is dumping this to the page:
<a href="~/Here171201.aspx">
What changed between versions of IIS or .NET Framework could be causing this functionality to no longer work? The Tilde was definitely resolving in 1.1 - I have the exact same code deployed on a dozen 1.1 Framework servers in our organization. Unfortunately, the class that sets the DataNavigateUrlFormatString doesn't have access to the Page, so I'll have to do some kludging to insert the Page.ResolveUrl work around...
I'm not aware of anything changing, but I don't use HyperLinkColumns (I prefer the control which the Template column provides) so I've not looked for any changes .
One possibility as a proverbial band aid is to change this line:
oLink.DataNavigateUrlFormatString = "~/Here{0}.aspx";
to this:
oLink.DataNavigateUrlFormatString = Page.ResolveUrl("~/Here{0}.aspx");
If memory serves there was some issues when going to Master Pages and using the '~' from User Controls, but it's been a while since I read anything like that.
I don't think that the HyperlinkColumn of a Datagrid automatically resolves the URL into an absolute path. IIRC, the DataNavigateUrlFormatString property internally calls String.Format() only on the supplied format. Are you sure this worked correctly on .NET 1.1? IIRC, .NET 1.1 did not have tilde-based automatic URL resolution.
In my opinion, you should use the solution presented by Stephen (call Page.ResolveUrl manually.)