I have a asp.net project with a html file(Html 5). I am trying to set the SVG as background of my body tag using the CSS 3. I have my file like this.
In my Style.css.
when i double click and open the html file. i can see the body filled with SVG, but this is not working when i debug with VS 2010.
This is what i got when i debug the html using the vs 2010.
Is any thing i missed here ? how to fix this ?
My workaround for this was to create my own httphandler locally which overwrote the content-type for svg.
public class SvgHandler : IHttpHandler
{
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "image/svg+xml";
context.Response.BinaryWrite(File.ReadAllBytes(context.Request.PhysicalPath));
context.Response.End();
}
}
and in web.config i added:
<httpHandlers>
<add verb="*" path="*.svg" type="SvgHandler" />
</httpHandlers>
with this solution you don't have to use IIS express, you can just use the regular development server in visual studio 2010
The built-in Visual Studio web server only has a limited set of mime-types it can serve. SVG is not one of them.
See here for a concise answer:
https://serverfault.com/questions/359904/how-to-configure-iis-for-svg-and-web-testing-with-visual-studio
Related
I am adding some more control to a win form I created that runs from a .dll
The project loaded fine, after I made some changes to the form in the form visual designer, compiled and then tried to open the form... I was fronted with this error screen.
It is complaining because it can't find the NoButtonsTabControl class.
The NoTabControl.cs class:
namespace TFG_Tools {
// Extend TabControl Class to provide a multi layer canvas with hidden tabs or buttons
public class NoButtonsTabControl : TabControl {
public NoButtonsTabControl() {
Appearance = TabAppearance.FlatButtons;
ItemSize = new Size(0, 1);
//SizeMode = TabSizeMode.Fixed;
}
protected override void WndProc(ref Message m) {
// Hide tabs by trapping the TCM_ADJUSTRECT message
if (m.Msg == 0x1328) m.Result = (IntPtr)1;
else base.WndProc(ref m);
}
}// end NoButtonsTabControl class
}
The start of the main form class looks like this...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using ENSED;
using System.Globalization;
using Win32;
using WindowsEnv;
namespace TFG_Tools {
public partial class TradePanelForm : Form {
//loaded as master
private bool isMaster = false;
public void SetAsMaster() { isMaster = true; }
...
Why has this suddenly just happened now, so frustrating. I am only intermediate with c# and visual studio. I only used it for this project to create the winform.
How do I tell the designer where this class is, so this error stops appearing?
The funny thing is, it worked fine before, with this arrangement! And if I compile the code, it works, and all the form elements are there.
It's just the designer which is dying atm.
P.S I also moved this project over from Virtual Studio 2015
Thank you.
My solution to this was weird.
close down all open windows in your project
Select the "any cpu" profile
go build->clean solution
Then build->rebuild solution
Re open your form designer
This worked for me, and hopefully will clear this mess up each time it pops up.
I have 2 profiles, a 32bit and 64bit profile so I can compile the dll to both.
Something must break in the designer when I switch to these profiles to build the project.
Hopefully this saves time for others.
I created a VISX project, and wrote this piece of code:
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.TextManager.Interop;
using System.ComponentModel.Composition;
namespace MyExtension
{
[Export(typeof(IVsTextViewCreationListener))]
public class Main : IVsTextViewCreationListener
{
public void VsTextViewCreated(IVsTextView textViewAdapter)
{
}
}
}
If I put a breakpoint inside the VsTextViewCreated method, Visual Studio informs me that it will never be hit. Opening files in the second instance of Visual Studio that launches in the debugger indeed does not trigger it.
What am I doing wrong?
You need to specify ContentType and TextViewRole for your class:
[Microsoft.VisualStudio.Utilities.ContentType("text")]
[Microsoft.VisualStudio.Text.Editor.TextViewRole(Microsoft.VisualStudio.Text.Editor.PredefinedTextViewRoles.Editable)]
Also don't forget to declare a MefComponent asset in your extension manifest:
And make sure in .csproj:
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
I've gotten .Net MVC3 to process .html (and other custom extension) just like a .cshtml file but VS2010 will not highlight the Razor syntax or show Intellisense for it. How do I get VS2010 to recognize .html file as .cshtml?
It's not so easy. If you see asp.net mvc 3 source, you can see in webpages folder next things:
File: RazorDebugHelpers.cs
// Trim the html part of cshtml or vbhtml
string outputExtension = extension.Substring(0, 3);
File: RazorCodeLanguage.cs
private static IDictionary<string, RazorCodeLanguage> _services = new Dictionary<string, RazorCodeLanguage>(StringComparer.OrdinalIgnoreCase) {
{ "cshtml", new CSharpRazorCodeLanguage() },
{ "vbhtml", new VBRazorCodeLanguage() }
};
File: PreApplicationStartCode.cs
WebPageHttpHandler.RegisterExtension("cshtml");
WebPageHttpHandler.RegisterExtension("vbhtml");
And so on.
What i want to say? Extension logic very deep in mvc. If you want to do something like that you prorably need to download sources, edit them and build custom library, but it's very time expensive. Maybe you can ask you question by other way, I hope exist better solution for your problem.
I have a strongly-typed view with a #model declaration:
#model MyViewModel
When using extension methods like this in my Razor views:
#Html.TextBoxFor(m => m.Foo)
Visual Studio shows errors like this:
The type arguments for method 'System.Web.Mvc.Html.InputExtensions.TextBoxFor<TModel,TProperty>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TProperty>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
These are only errors shown for the editor window; the view renders just fine at runtime.
Does this happen for everyone, or is there something I can do to make the Razor editor work better?
Thanks to this answer, I found the solution. In my web.config, once I specified a targetFramework attribute in my system.web/compilation config section, all of those nasty warnings disappeared. Previously, no targetFramework was specified. Strangely, Visual Studio doesn't just use the target framework of your project:
<compilation debug="true" targetFramework="4.0">
<!-- ... -->
</compilation>
I think it is just because razor compiler has no idea what type TModel should be.
I get the same errors and just ignore them because, it works so I am happy inside. But you could possibly try something like this, although having written it I think it's retarded and probably epicly useless but maybe someone else can shed some light on why it is retarded and the actual solution to avoiding these errors.
public class SomeBlah {
public Blah blahs { get; set; }
}
public class Blah {
public string Rawr { get; set; }
}
#model SomeBlah
#Html.TextBoxFor<Blah, string>(s => s.rawr)
Make sure that the web.config file in your web project has the correct namespaces imported. There's a chance your deployed website is using a different web.config than the one visual studio is using to parse the razor file.
I'm trying to upgrade some Sharepoint 2007 webparts to SP2010 using the web part projects built into Visual Studio 2010. Namely, I'm using Visual Web Part to migrate our existing controls, which make extensive use of ObjectDataSource. However, when adding an ODS to the control in the Visual Web Part project, it will not pick up objects in referenced class library projects. I was able to duplicate the problem from a clean setup as follows:
Create a new Visual Web Part
Add a new class library to the solution.
Class code is as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WebPartODS
{
[System.ComponentModel.DataObject(true)]
public class TestUser
{
[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select,false)]
public List<int> TestMethod()
{
return new List<int>();
}
}
}
Add the class library project as a reference in the Web Part project
In the VisualWebPart ascx file, add a objectdatasource in the Source view:
<asp:ObjectDataSource ID="TestOD" runat="server"></asp:ObjectDataSource>
Switch to Design view, bring up the "Configure data source" wizard. On the drop down, the class from the library project will not appear.
Is there a step that I am missing here, or is there an issue with trying to do it this way?
Ok, i got it to work. Here is where i got my answer: MSDN Forumn
I originally had a separate class for my business layer. I removed it and put my code in the ascx.cs file. Then I added the following line of code to my page load method.
ObjectDataSource1.TypeName = this.GetType().AssemblyQualifiedName;
I also removed the TypeName from the ascx page.